Prevent CSE for (ADD/SUB/MUL)_OV

This commit is contained in:
Dmitry Stogov 2022-11-03 15:58:51 +03:00
parent 56c22a205f
commit ef6b6c3e26

View File

@ -1829,8 +1829,6 @@ IR_FOLD(XOR(XOR, C_I64))
/* Swap operands (move lower ref to op2) for better CSE */
IR_FOLD(ADD(_, _))
IR_FOLD(MUL(_, _))
IR_FOLD(ADD_OV(_, _))
IR_FOLD(MUL_OV(_, _))
IR_FOLD_NAMED(swap_ops)
{
if (op1 < op2) { /* move lower ref to op2 */
@ -1842,6 +1840,25 @@ IR_FOLD_NAMED(swap_ops)
IR_FOLD_NEXT;
}
IR_FOLD(ADD_OV(_, _))
IR_FOLD(MUL_OV(_, _))
{
if (op1 < op2) { /* move lower ref to op2 */
ir_ref tmp = op1;
op1 = op2;
op2 = tmp;
IR_FOLD_RESTART;
}
/* skip CSE ??? */
IR_FOLD_EMIT;
}
IR_FOLD(SUB_OV(_, _))
{
/* skip CSE ??? */
IR_FOLD_EMIT;
}
/* Binary operations with op1 == op2 */
IR_FOLD(AND(_,_))
IR_FOLD(OR(_,_))