@@ -348,6 +348,7 @@ static int simplify_constant_rightside(struct instruction *insn)
case OP_ASR:
return simplify_asr(insn, insn->src1, value);
+ case OP_DIVU: case OP_DIVS:
case OP_MULU: case OP_MULS:
return simplify_mul_div(insn, value);
@@ -3,6 +3,8 @@ typedef int si;
si smul1(si a) { return a * 1; }
ui umul1(ui a) { return a * 1; }
+si sdiv1(si a) { return a / 1; }
+ui udiv1(ui a) { return a / 1; }
/*
* check-name: muldiv-by-one
@@ -10,4 +12,5 @@ ui umul1(ui a) { return a * 1; }
* check-output-ignore
*
* check-output-excludes: mul[us]\\.
+ * check-output-excludes: div[us]\\.
*/
Currently we simplify multiplication by 1 but nothing for the similar divide by 1. This patch add the missing simplification together with its test cases. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- simplify.c | 1 + validation/optim/muldiv-by-one.c | 3 +++ 2 files changed, 4 insertions(+)