[Nouveau] [PATCH v2] nv50/ir: constant fold OP_SPLIT

Tobias Klausmann tobias.johannes.klausmann at mni.thm.de
Fri Sep 30 22:27:22 UTC 2016



On 30.09.2016 23:57, Ilia Mirkin wrote:
> On Fri, Sep 30, 2016 at 5:50 PM, Tobias Klausmann
> <tobias.johannes.klausmann at mni.thm.de> wrote:
>> Split the source immediate value into two new values and create OP_MOV
>> instructions the two newly created values.
>>
>> V2: get rid of special cases
>>
>> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
>> ---
>>   src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
>>
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> index 9875738..d56b057 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> @@ -932,6 +932,22 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
>>      Instruction *newi = i;
>>
>>      switch (i->op) {
>> +   case OP_SPLIT: {
>> +      uint8_t size = typeSizeof(i->dType);
>> +      DataType type = typeOfSize(size / 2, isFloatType(i->dType),
>> +                                 isSignedType(i->dType));
> Er wait, sorry, I might have confused matters here...
>
> Why do you need to compute type at all? Why not just reuse i->dType?

i->dType comes in the same as i->sType, so we need to evaluate the old 
type and set the new type accordingly.
e.g in my test shader a u64 is split, still i->dType == TYPE_U64. Maybe 
we are doing something wrong somewhere else, but looking only at this 
folding, setting the new type is needed (note that originally i->sType 
was used)

>
>> +      if (likely(type != TYPE_NONE)) {
>> +         uint64_t val = imm0.reg.data.u64;
>> +         uint16_t shift = size * 8;
>> +         bld.setPosition(i, false);
>> +         for (int8_t d = 0; i->defExists(d); ++d) {
>> +            bld.mkMov(i->getDef(d), bld.mkImm(val & ((1 << shift) - 1)), type);
> 1ULL
>
>> +            val >>= shift;
>> +         }
>> +         delete_Instruction(prog, i);
>> +      }
>> +   }
>> +   break;
>>      case OP_MUL:
>>         if (i->dType == TYPE_F32)
>>            tryCollapseChainedMULs(i, s, imm0);
>> --
>> 2.10.0
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau



More information about the Nouveau mailing list