diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-02-07 21:50:26 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:46 +0800 |
| commit | f1252a541ac87e814018c0dd01c39ea6356530eb (patch) | |
| tree | cc6d7a289aaa98cb24405b890e2c0bdf1f63b380 /validation/optim/muldiv-minus-one.c | |
| parent | e6328bea9acbbcd68d6abfad8d9d16a42590e378 (diff) | |
| download | sparse-dev-f1252a541ac87e814018c0dd01c39ea6356530eb.tar.gz | |
simplify '(x * -1)' to '-x'
Currently we simplify multiplication by 1 but nothing is
done for multiplication by -1 which is equivalent to the
negation of its first operand.
This patch add this simplification.
Also add small test cases showing the simplification.
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 | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/validation/optim/muldiv-minus-one.c b/validation/optim/muldiv-minus-one.c new file mode 100644 index 00000000..729b7344 --- /dev/null +++ b/validation/optim/muldiv-minus-one.c @@ -0,0 +1,13 @@ +typedef unsigned int u32; + +int smulm1(int a) { return a * -1; } +u32 umulm1(u32 a) { return a * (u32) -1; } + +/* + * check-name: muldiv-minus-one + * check-command: test-linearize -Wno-decl $file + * check-output-ignore + * + * check-output-excludes: mul[us]\\. + * check-output-contains: neg\\. + */ |
