From e6328bea9acbbcd68d6abfad8d9d16a42590e378 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Tue, 7 Feb 2017 21:50:25 +0100 Subject: [PATCH] simplify '(x / 1)' to 'x' 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 Signed-off-by: Christopher Li --- simplify.c | 1 + validation/optim/muldiv-by-one.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/simplify.c b/simplify.c index 47ec780c..ed6cc41b 100644 --- a/simplify.c +++ b/simplify.c @@ -375,6 +375,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); diff --git a/validation/optim/muldiv-by-one.c b/validation/optim/muldiv-by-one.c index ac8ac95b..f6dd7cb2 100644 --- a/validation/optim/muldiv-by-one.c +++ b/validation/optim/muldiv-by-one.c @@ -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]\\. */ -- 2.11.4.GIT