All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Klausmann <tobias.johannes.klausmann-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
To: Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
Cc: "nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [RESEND/PATCH] nv50/ir: Handle OP_CVT when folding constant expressions
Date: Sat, 10 Jan 2015 02:08:39 +0100	[thread overview]
Message-ID: <54B07B97.6090707@mni.thm.de> (raw)
In-Reply-To: <CAKb7UvhkHtoRFP1rk8=9w68ZcgesV21mGAMmdB5LsHvFVNzo3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>



On 10.01.2015 02:41, Ilia Mirkin wrote:
> On Fri, Jan 9, 2015 at 6:47 PM, Tobias Klausmann
> <tobias.johannes.klausmann@mni.thm.de> wrote:
>> Folding for conversions: F32->(U{16/32}, S{16/32}) and (U{16/32}, {S16/32})->F32
>>
>> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
>> ---
>>   .../drivers/nouveau/codegen/nv50_ir_peephole.cpp   | 109 +++++++++++++++++++++
>>   1 file changed, 109 insertions(+)
>>
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> index 9a0bb60..6a3d515 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> @@ -997,6 +997,115 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
>>         i->op = OP_MOV;
>>         break;
>>      }
>> +   case OP_CVT: {
>> +      Storage res;
>> +      bld.setPosition(i, true); /* make sure bld is init'ed */
>> +      switch(i->dType) {
>> +      case TYPE_U16:
>> +         switch (i->sType) {
>> +         case TYPE_F32:
>> +            if (i->saturate)
>> +               res.data.u16 = util_iround(CLAMP(imm0.reg.data.f32, 0,
>> +                                                UINT16_MAX));
>> +            else
>> +               res.data.u16 = util_iround(imm0.reg.data.f32);
>> +            break;
>> +         case TYPE_F64:
> The F64 stuff needs more thought, as I don't think we can always store
> the f64 immediates. In my patches, I just outlaw fp64 immediates in
> the first place. Please leave these out for now.

Oh i removed only the lower part of it, i beg you pardon for delivering 
that thing here :/
>
>> +            if (i->saturate)
>> +               res.data.u16 = util_iround(CLAMP(imm0.reg.data.f64, 0,
>> +                                                UINT16_MAX));
>> +            else
>> +               res.data.u16 = util_iround(imm0.reg.data.f64);
>> +            break;
>> +         default:
>> +            return;
>> +         }
>> +         i->setSrc(0, bld.mkImm(res.data.u16));
>> +         break;
>> +      case TYPE_U32:
>> +         switch (i->sType) {
>> +         case TYPE_F32:
>> +            if (i->saturate)
>> +               res.data.u32 = util_iround(CLAMP(imm0.reg.data.f32, 0,
>> +                                                UINT32_MAX));
>> +            else
>> +               res.data.u32 = util_iround(imm0.reg.data.f32);
>> +            break;
>> +         case TYPE_F64:
>> +            if (i->saturate)
>> +               res.data.u32 = util_iround(CLAMP(imm0.reg.data.f64, 0,
>> +                                                UINT32_MAX));
>> +            else
>> +               res.data.u32 = util_iround(imm0.reg.data.f64);
>> +         break;
>> +         default:
>> +            return;
>> +         }
>> +         i->setSrc(0, bld.mkImm(res.data.u32));
>> +         break;
>> +      case TYPE_S16:
>> +         switch (i->sType) {
>> +         case TYPE_F32:
>> +            if (i->saturate)
>> +               res.data.s16 = util_iround(CLAMP(imm0.reg.data.f32, INT16_MIN,
>> +                                                INT16_MAX));
>> +            else
>> +               res.data.s16 = util_iround(imm0.reg.data.f32);
>> +            break;
>> +         case TYPE_F64:
>> +            if (i->saturate)
>> +               res.data.s16 = util_iround(CLAMP(imm0.reg.data.f64, INT16_MIN,
>> +                                                INT16_MAX));
>> +            else
>> +               res.data.s16 = util_iround(imm0.reg.data.f64);
>> +         break;
>> +         default:
>> +            return;
>> +         }
>> +         i->setSrc(0, bld.mkImm(res.data.s16));
>> +         break;
>> +      case TYPE_S32:
>> +         switch (i->sType) {
>> +         case TYPE_F32:
>> +            if (i->saturate)
>> +               res.data.s32 = util_iround(CLAMP(imm0.reg.data.f32, INT32_MIN,
>> +                                               INT32_MAX));
>> +            else
>> +               res.data.s32 = util_iround(imm0.reg.data.f32);
>> +            break;
>> +         case TYPE_F64:
>> +            if (i->saturate)
>> +               res.data.s32 = util_iround(CLAMP(imm0.reg.data.f64, INT32_MIN,
>> +                                               INT32_MAX));
>> +            else
>> +               res.data.s32 = util_iround(imm0.reg.data.f64);
>> +            break;
>> +         default:
>> +            return;
>> +         }
>> +         i->setSrc(0, bld.mkImm(res.data.s32));
>> +         break;
>> +      case TYPE_F32:
>> +         switch (i->sType) {
>> +         case TYPE_U16: res.data.f32 = (float) imm0.reg.data.u16; break;
>> +         case TYPE_U32: res.data.f32 = (float) imm0.reg.data.u32; break;
>> +         case TYPE_S16: res.data.f32 = (float) imm0.reg.data.s16; break;
>> +         case TYPE_S32: res.data.f32 = (float) imm0.reg.data.s32; break;
>> +         default:
>> +            return;
>> +         }
>> +         i->setSrc(0, bld.mkImm(res.data.f32));
>> +         break;
>> +      default:
>> +         return;
>> +      }
>> +      i->setType(i->dType); /* Remove i->sType, which we don't need anymore */
>> +      i->setSrc(1, NULL);
>> +      i->op = OP_MOV;
>> +
>> +      i->src(0).mod = Modifier(0); /* Clear the already applied modifier */
>> +      break;
>> +   }
>>      default:
>>         return;
>>      }
>> --
>> 2.2.1
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

  parent reply	other threads:[~2015-01-10  1:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 23:47 [RESEND/PATCH] nv50/ir: Handle OP_CVT when folding constant expressions Tobias Klausmann
     [not found] ` <1420847276-8754-1-git-send-email-tobias.johannes.klausmann-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-10  1:41   ` Ilia Mirkin
     [not found]     ` <CAKb7UvhkHtoRFP1rk8=9w68ZcgesV21mGAMmdB5LsHvFVNzo3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-10  1:08       ` Tobias Klausmann [this message]
2015-01-10  1:24       ` [PATCH v2] " Tobias Klausmann
     [not found]         ` <1420853067-13115-1-git-send-email-tobias.johannes.klausmann-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11  0:58           ` Ilia Mirkin
     [not found]             ` <CAKb7UvinNbgsgz7PGzzy0fAmfzAykm9Fph_FRDxoZKV5cS+ybg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-11 17:27               ` Tobias Klausmann
     [not found]                 ` <54B2B283.9020400-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11 19:19                   ` Ilia Mirkin
     [not found]                     ` <CAKb7Uvg_dR3U_swgod0oLb5cLm8OX8OtTQPU514VG92G1vYg2A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-11 19:56                       ` Tobias Klausmann
     [not found]                         ` <54B2D552.6030700-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11 19:57                           ` Ilia Mirkin
     [not found]                             ` <CAKb7Uvi7Ke_fzbpQ_JvLvv-1u2H=F-udRdb0A+dCM0=tsqBKBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-11 20:17                               ` Tobias Klausmann
     [not found]                                 ` <54B2DA6A.7080505-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11 21:40                                   ` [PATCH] " Tobias Klausmann
     [not found]                                     ` <1421012422-30607-1-git-send-email-tobias.johannes.klausmann-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11 21:54                                       ` Ilia Mirkin
     [not found]                                         ` <CAKb7Uvgnd25Ubm4m_-auNHw8p_Z9g=7sSxDrRb+CmbE5MZtohA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-11 22:08                                           ` Tobias Klausmann
     [not found]                                             ` <54B2F467.3050007-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11 22:12                                               ` Ilia Mirkin
     [not found]                                                 ` <CAKb7UvgiWyNAumaKaiw_B2f49Q+xXszdwBE1abJwoC8SEpH8Lg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-11 22:48                                                   ` Tobias Klausmann
     [not found]                                                     ` <54B2FDB9.60906-AqjdNwhu20eELgA04lAiVw@public.gmane.org>
2015-01-11 22:53                                                       ` Ilia Mirkin
     [not found]                                                         ` <CAKb7UvidgoVLmvvG3r2M2Eio-EexLh1RsXh9GK8Pf-UMSVOPgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-24 18:18                                                           ` [PATCH v4] " Tobias Klausmann
2015-01-24 18:19                                                           ` [PATCH] " Tobias Klausmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B07B97.6090707@mni.thm.de \
    --to=tobias.johannes.klausmann-aqjdnwhu20eelga04laivw@public.gmane.org \
    --cc=imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.