[Mesa-dev] [PATCH v2 4/7] nv50/ir: optimize shl(shr(a, c), c) to and(a, ~((1 << c) - 1))
Karol Herbst
nouveau at karolherbst.de
Wed Jan 27 09:25:05 PST 2016
From: Karol Herbst <git at karolherbst.de>
helps shaders in multiple games
total instructions in shared programs : 1910935 -> 1901781 (-0.48%)
total gprs used in shared programs : 251728 -> 251728 (0.00%)
total local used in shared programs : 5673 -> 5673 (0.00%)
total bytes used in shared programs : 17521824 -> 17438576 (-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>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
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 eb43f6c..abee6a5 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