From ae828413c4a98ba3546f5586f2e20d9da718ab0c Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 7 Jan 2012 18:42:13 +0100 Subject: nv50/ir/opt: optimize u32 MOD by power of 2 into AND --- src/gallium/drivers/nv50/codegen/nv50_ir_peephole.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gallium/drivers/nv50') 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)); -- cgit v1.2.3