[Mesa-dev] [PATCH] nv50/ir: optimise slct(t, f, set) to mov(set) or not(set)

Karol Herbst kherbst at redhat.com
Tue Mar 27 22:29:46 UTC 2018


On Tue, Mar 27, 2018 at 11:19 PM, Ian Romanick <idr at freedesktop.org> wrote:
> It will be interesting to see if this still occurs after nouveau
> finishes switching to NIR.  There's a pattern in nir_opt_algebraic for this.
>

well there is no plan to switch to NIR for everything where we can use TGSI.

> On 03/27/2018 01:50 PM, Karol Herbst wrote:
>> From: Karol Herbst <karolherbst at gmail.com>
>>
>> helps mainly Feral-ported games
>>
>> changes in shader-db:
>> total instructions in shared programs : 3940749 -> 3935015 (-0.15%)
>> total gprs used in shared programs    : 481460 -> 481433 (-0.01%)
>> total local used in shared programs   : 27481 -> 27513 (0.12%)
>> total bytes used in shared programs   : 36115776 -> 36063344 (-0.15%)
>>
>>                 local        gpr       inst      bytes
>>     helped           6          31         854         854
>>       hurt          10           5           1           1
>> ---
>>  .../drivers/nouveau/codegen/nv50_ir_peephole.cpp   | 26 ++++++++++++++++++++--
>>  1 file changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> index 48cf74950df..1e3dea95494 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>> @@ -637,9 +637,31 @@ ConstantFolding::expr(Instruction *i,
>>        }
>>        break;
>>     case OP_SLCT:
>> -      if (a->data.u32 != b->data.u32)
>> +      // slct(a, a, b) -> a
>> +      if (a->data.u32 == b->data.u32) {
>> +         res.data.u32 = a->data.u32;
>> +      } else {
>> +         // slct_ne(true, false, bool) -> !bool
>> +         CmpInstruction *slct = i->asCmp();
>> +         Instruction *set = i->getSrc(2)->getInsn();
>> +         if (!set || set->op != OP_SET)
>> +            return;
>> +         if (isFloatType(set->dType))
>> +            return;
>> +         if ((slct->getCondition() == CC_NE && imm0.isInteger(-1) && imm1.isInteger(0)) ||
>> +             (slct->getCondition() == CC_EQ && imm0.isInteger(0) && imm1.isInteger(-1))) {
>> +            bld.setPosition(i, false);
>> +            bld.mkOp1(OP_MOV, i->dType, i->getDef(0), i->getSrc(2));
>> +            delete_Instruction(prog, i);
>> +         } else if (
>> +             (slct->getCondition() == CC_EQ && imm0.isInteger(-1) && imm1.isInteger(0)) ||
>> +             (slct->getCondition() == CC_NE && imm0.isInteger(0) && imm1.isInteger(-1))) {
>> +            bld.setPosition(i, false);
>> +            bld.mkOp1(OP_NOT, i->dType, i->getDef(0), i->getSrc(2));
>> +            delete_Instruction(prog, i);
>> +         }
>>           return;
>> -      res.data.u32 = a->data.u32;
>> +      }
>>        break;
>>     case OP_EXTBF: {
>>        int offset = b->data.u32 & 0xff;
>>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list