Only and only if src1 is a power of 2 we can replace IMAD by SHLADD.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
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;
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: