A previous patch added the simplification for multiply by -1 but we can do the same for the signed divide. This patch add this simplification Also add the corresponding test cases. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 3 ++- validation/optim/muldiv-minus-one.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/simplify.c b/simplify.c index 6c7c79e9..e3e5ff6e 100644 --- a/simplify.c +++ b/simplify.c @@ -324,6 +324,8 @@ static int simplify_mul_div(struct instruction *insn, long long value) if (value == 0) return replace_with_pseudo(insn, insn->src2); + /* Fall through */ + case OP_DIVS: if (!(value & sbit)) // positive break; @@ -333,7 +335,6 @@ static int simplify_mul_div(struct instruction *insn, long long value) return REPEAT_CSE; } /* Fall through */ - case OP_DIVS: case OP_DIVU: break; } diff --git a/validation/optim/muldiv-minus-one.c b/validation/optim/muldiv-minus-one.c index 729b7344..05a5f915 100644 --- a/validation/optim/muldiv-minus-one.c +++ b/validation/optim/muldiv-minus-one.c @@ -2,6 +2,7 @@ typedef unsigned int u32; int smulm1(int a) { return a * -1; } u32 umulm1(u32 a) { return a * (u32) -1; } +int sdivm1(int a) { return a * -1; } /* * check-name: muldiv-minus-one @@ -9,5 +10,6 @@ u32 umulm1(u32 a) { return a * (u32) -1; } * check-output-ignore * * check-output-excludes: mul[us]\\. + * check-output-excludes: divs\\. * check-output-contains: neg\\. */ -- 2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html