diff options
author | Samuel Pitoiset <[email protected]> | 2016-09-14 18:49:36 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2016-09-29 21:20:41 +0200 |
commit | e4eb0fca024babcd7bea2b34a7e7605287963ce0 (patch) | |
tree | 1120256d9daa92695668dfe39c0b290f8119e4c7 /src/gallium/drivers/nouveau/codegen | |
parent | 31545b64b80aa939a693723e07f06fe45160ae62 (diff) |
nv50/ir: optimize IMAD to SHLADD in presence of power of 2
Only and only if src1 is a power of 2 we can replace IMAD by SHLADD.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/gallium/drivers/nouveau/codegen')
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp index 74a5a854e77..c9d5b5f7d65 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp @@ -915,6 +915,7 @@ ConstantFolding::opnd3(Instruction *i, ImmediateValue &imm2) void ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) { + const Target *target = prog->getTarget(); const int t = !s; const operation op = i->op; Instruction *newi = i; @@ -1016,6 +1017,12 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) i->src(1).mod = i->src(2).mod; i->setSrc(2, NULL); i->op = OP_ADD; + } else + if (s == 1 && !imm0.isNegative() && imm0.isPow2() && + target->isOpSupported(i->op, i->dType)) { + i->op = OP_SHLADD; + imm0.applyLog2(); + i->setSrc(1, new_ImmediateValue(prog, imm0.reg.data.u32)); } break; case OP_ADD: |