nv50/ir/opt: optimize u32 MOD by power of 2 into AND

This commit is contained in:
Christoph Bumiller 2012-01-07 18:42:13 +01:00
parent 6ab6110133
commit ae828413c4
1 changed files with 8 additions and 0 deletions

View File

@ -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));