diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2016-12-07 17:13:24 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:46 +0800 |
| commit | a0886db12307d2633b04ec44342099a2955794a5 (patch) | |
| tree | c18df7caf796801fb1109dc1165622f00b2ee92e /validation/optim | |
| parent | 5425db10d4d35895ba3ca390478c624233ec027d (diff) | |
| download | sparse-dev-a0886db12307d2633b04ec44342099a2955794a5.tar.gz | |
simplify '(x || 1)' to '1'
There is simplifications for:
(x && 0) => 0
(x && 1) => x
(x || 0) => x
but the fourth case '(x || 1)' is missing.
This patch add the missing simplification and a small test case.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/bool-simplify.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/validation/optim/bool-simplify.c b/validation/optim/bool-simplify.c new file mode 100644 index 00000000..e0ff1c2d --- /dev/null +++ b/validation/optim/bool-simplify.c @@ -0,0 +1,51 @@ +int and_0(int a) +{ + return a && 0; +} + +int and_1(int a) +{ + return a && 1; +} + +int or_0(int a) +{ + return a || 0; +} + +int or_1(int a) +{ + return a || 1; +} + +/* + * check-name: bool-simplify + * check-command: test-linearize -Wno-decl $file + * + * check-output-start +and_0: +.L0: + <entry-point> + ret.32 $0 + + +and_1: +.L2: + <entry-point> + ret.32 %arg1 + + +or_0: +.L4: + <entry-point> + ret.32 %arg1 + + +or_1: +.L6: + <entry-point> + ret.32 $1 + + + * check-output-end + */ |
