[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:33:05 UTC 2018
On Tue, Mar 27, 2018 at 11:04 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Tue, Mar 27, 2018 at 4:50 PM, Karol Herbst <kherbst at redhat.com> 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
>
> Can you look at the local memory regressions and see what happened?
> Seems like local went up a lot.
>
well yeah, it only happened in shaders which were already spilling and
we ended up with spilling sillyness again where a spilled value was
loaded from lmem allthough we could have used the registers in that
BB.
>> ---
>> .../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));
>
> dType should always be U32 for MOV and NOT.
>
>> + delete_Instruction(prog, i);
>> + }
>
> Don't forget to indicate that you made progress (if you did).
>
>> return;
>> - res.data.u32 = a->data.u32;
>> + }
>> break;
>> case OP_EXTBF: {
>> int offset = b->data.u32 & 0xff;
>> --
>> 2.14.3
>>
>> _______________________________________________
>> 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