Only unsigned MOD may be converted into AND

This commit is contained in:
Dmitry Stogov 2022-07-21 20:45:19 +03:00
parent e235a33679
commit 1089699f2c

View File

@ -1428,7 +1428,9 @@ binop_fp:
op2_insn = &ctx->ir_base[insn->op2];
if (IR_IS_CONST_REF(insn->op1)) {
// const
} else if (IR_IS_POWER_OF_TWO(op2_insn->val.u64) && IR_IS_UNSIGNED_32BIT(op2_insn->val.u64 - 1)) {
} else if (IR_IS_TYPE_UNSIGNED(insn->type)
&& IR_IS_POWER_OF_TWO(op2_insn->val.u64)
&& IR_IS_UNSIGNED_32BIT(op2_insn->val.u64 - 1)) {
return IR_MOD_PWR2; // and op1, op2_insn->val.u64-1
}
}