From: Christoph Bumiller Date: Sat, 7 Jan 2012 17:42:13 +0000 (+0100) Subject: nv50/ir/opt: optimize u32 MOD by power of 2 into AND X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae828413c4a98ba3546f5586f2e20d9da718ab0c;p=mesa.git nv50/ir/opt: optimize u32 MOD by power of 2 into AND --- diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp index 2a7a981ac61..fc025d8767e 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp @@ -698,6 +698,14 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue *src, int s) } break; + case OP_MOD: + if (i->sType == TYPE_U32 && imm.isPow2()) { + bld.setPosition(i, false); + i->op = OP_AND; + i->setSrc(1, bld.loadImm(NULL, imm.reg.data.u32 - 1)); + } + break; + case OP_SET: // TODO: SET_AND,OR,XOR { CmpInstruction *si = findOriginForTestWithZero(i->getSrc(t));