[Mesa-dev] [PATCH 2/2] nv50/ir: optimize sub(a, 0) to a
Karol Herbst
nouveau at karolherbst.de
Wed Feb 17 21:21:43 UTC 2016
helps a 0ad shader in default shader-db:
total instructions in shared programs : 102863 -> 102861 (-0.00%)
total gprs used in shared programs : 14725 -> 14725 (0.00%)
total local used in shared programs : 129 -> 129 (0.00%)
total bytes used in shared programs : 943944 -> 943928 (-0.00%)
local gpr inst bytes
helped 0 0 1 1
hurt 0 0 0 0
helps some borderlands shaders:
total instructions in shared programs : 1794261 -> 1794255 (-0.00%)
total gprs used in shared programs : 233059 -> 233059 (0.00%)
total local used in shared programs : 5569 -> 5569 (0.00%)
total bytes used in shared programs : 16451664 -> 16451616 (-0.00%)
local gpr inst bytes
helped 0 0 3 3
hurt 0 0 0 0
Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
---
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 5c3ee37..fa07dff 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -1003,12 +1003,15 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
}
break;
case OP_ADD:
+ case OP_SUB:
if (i->usesFlags())
break;
if (imm0.isInteger(0)) {
if (s == 0) {
i->setSrc(0, i->getSrc(1));
i->src(0).mod = i->src(1).mod;
+ if (i->op == OP_SUB)
+ i->src(0).mod = i->src(0).mod ^ Modifier(NV50_IR_MOD_NEG);
}
i->setSrc(1, NULL);
i->op = i->src(0).mod.getOp();
--
2.7.1
More information about the mesa-dev
mailing list