diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2016-12-11 22:13:27 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:46 +0800 |
| commit | e5f70312b25b77a57a2ca16acb94d726af15f5f9 (patch) | |
| tree | 32aa7fb91abf0e7b3112cc650fb9cb11968119e7 /validation/optim/setcc-seteq.c | |
| parent | 77ec9f360da23218a1d7447540302ff77e933a99 (diff) | |
| download | sparse-dev-e5f70312b25b77a57a2ca16acb94d726af15f5f9.tar.gz | |
simplify comparisons followed by an equality test against 0 or 1
Expressions involving equality testing against zero are ubiquitious
and can often be simplified with previous comparisons.
For example, when using test-linearize on the following code:
_Bool foo(int a) { return !(a < 3); }
the following was emitted:
setlt.32 %r2 <- %arg1, $3
seteq.32 %r3 <- %r2, $0
setne.1 %r4 <- %r3, $0
ret.1 %r4
but this can be simplified into:
setge.1 %r4 <- %arg1, $3
ret.1 %r4
Implement this simplification and add associated 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/setcc-seteq.c')
| -rw-r--r-- | validation/optim/setcc-seteq.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/validation/optim/setcc-seteq.c b/validation/optim/setcc-seteq.c new file mode 100644 index 00000000..d8765fe1 --- /dev/null +++ b/validation/optim/setcc-seteq.c @@ -0,0 +1,13 @@ +static _Bool beq0(int a) { return (a == 0); } +static _Bool bnotneq0(int a) { return !(a != 0); } +static _Bool bnot(int a) { return !a; } + +/* + * check-name: optim/setcc-seteq + * check-command: test-linearize $file + * check-output-ignore + * + * check-output-excludes: set..\\.32 + * check-output-excludes: setne\\.1 + * check-output-contains: seteq\\.1 + */ |
