From 0ef5c8ab7405fcc76b23393d4414f46cc9edb1fc Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Fri, 4 Dec 2015 17:26:32 -0500 Subject: [PATCH] nv50/ir: fold shl + mul with immediates On SM20 this gives: total instructions in shared programs : 6299222 -> 6294240 (-0.08%) total gprs used in shared programs : 944139 -> 944068 (-0.01%) total local used in shared programs : 54116 -> 54116 (0.00%) local gpr inst bytes helped 0 126 2781 2781 hurt 0 55 11 11 Signed-off-by: Ilia Mirkin --- src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 0d74f72..9f44628 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -1194,6 +1194,22 @@ 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_MUL: + int muls; + if (isFloatType(si->dType)) + return; + if (si->src(1).getImmediate(imm1)) + muls = 1; + else if (si->src(0).getImmediate(imm1)) + muls = 0; + else + return; + + bld.setPosition(i, false); + i->op = OP_MUL; + i->setSrc(0, si->getSrc(!muls)); + i->setSrc(1, bld.loadImm(NULL, imm1.reg.data.u32 << imm0.reg.data.u32)); + break; case OP_SUB: case OP_ADD: int adds; -- 2.7.4