simplify comparisons followed by an equality test against 0 or 1
commite5f70312b25b77a57a2ca16acb94d726af15f5f9
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Sun, 11 Dec 2016 21:13:27 +0000 (11 22:13 +0100)
committerChristopher Li <sparse@chrisli.org>
Mon, 13 Feb 2017 01:34:46 +0000 (13 09:34 +0800)
tree32aa7fb91abf0e7b3112cc650fb9cb11968119e7
parent77ec9f360da23218a1d7447540302ff77e933a99
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>
simplify.c
validation/optim/setcc-setcc.c [new file with mode: 0644]
validation/optim/setcc-seteq.c [new file with mode: 0644]
validation/optim/setcc-setne.c [new file with mode: 0644]