[Mesa-dev] [PATCH 4/6] nv50/ir: optimize shl(shr(a, c), c) to and(a, ~((1 << c) - 1))
Karol Herbst
nouveau at karolherbst.de
Mon Jan 25 06:57:51 PST 2016
From: Karol Herbst <git at karolherbst.de>
helps shaders in multiple games
total instructions in shared programs : 1911112 -> 1901958 (-0.48%)
total gprs used in shared programs : 251739 -> 251739 (0.00%)
total local used in shared programs : 5673 -> 5673 (0.00%)
total bytes used in shared programs : 17523440 -> 17440184 (-0.48%)
local gpr inst bytes
helped 0 0 1387 1387
hurt 0 0 0 0
Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
---
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 8dc0844..142d9a7 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1202,6 +1202,14 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
i->setSrc(1, bld.loadImm(NULL, imm0.reg.data.u32 + imm1.reg.data.u32));
}
break;
+ case OP_SHR:
+ if (si->src(1).getImmediate(imm1) && imm0.reg.data.u32 == imm1.reg.data.u32) {
+ bld.setPosition(i, false);
+ i->op = OP_AND;
+ i->setSrc(0, si->getSrc(0));
+ i->setSrc(1, bld.loadImm(NULL, ~((1 << imm0.reg.data.u32) - 1)));
+ }
+ break;
case OP_MUL:
int muls;
if (isFloatType(si->dType))
--
2.7.0
More information about the mesa-dev
mailing list