diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-02-07 21:50:27 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:46 +0800 |
| commit | f4615a44a2ab133b90a9c9eb9bc7861fa66dfa46 (patch) | |
| tree | 4889a4792818b1217bcb6dd9bddcab07d4bf475d /validation/optim/muldiv-minus-one.c | |
| parent | f1252a541ac87e814018c0dd01c39ea6356530eb (diff) | |
| download | sparse-dev-f4615a44a2ab133b90a9c9eb9bc7861fa66dfa46.tar.gz | |
simplify '(x / -1)' to '-x' (but only for signed division)
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@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation/optim/muldiv-minus-one.c')
| -rw-r--r-- | validation/optim/muldiv-minus-one.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/validation/optim/muldiv-minus-one.c b/validation/optim/muldiv-minus-one.c index 729b7344..42b086af 100644 --- a/validation/optim/muldiv-minus-one.c +++ b/validation/optim/muldiv-minus-one.c @@ -2,6 +2,8 @@ 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; } +u32 udivm1(u32 a) { return a / (u32) -1; } /* * check-name: muldiv-minus-one @@ -9,5 +11,8 @@ u32 umulm1(u32 a) { return a * (u32) -1; } * check-output-ignore * * check-output-excludes: mul[us]\\. + * check-output-excludes: divs\\. * check-output-contains: neg\\. + * check-output-contains: divu\\. + * check-output-pattern-3-times: neg\\. */ |
