New testcase for instcombine
[oota-llvm.git] / test / Transforms / InstCombine / sub.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: if as < %s | opt -instcombine -die | dis | grep sub | grep -v 'sub int %Cok, %Bok'
5 ; RUN: then exit 1
6 ; RUN: else exit 0
7 ; RUN: fi
8
9 implementation
10
11 int "test1"(int %A) {
12         %B = sub int %A, %A    ; ISA constant 0
13         ret int %B
14 }
15
16 int "test2"(int %A) {
17         %B = sub int %A, 0
18         ret int %B
19 }
20
21 int "test3"(int %A) {
22         %B = sub int 0, %A       ; B = -A
23         %C = sub int 0, %B       ; C = -B = A
24         ret int %C
25 }
26
27 int "test4"(int %A, int %x) {
28         %B = sub int 0, %A
29         %C = sub int %x, %B
30         ret int %C
31 }
32
33 int "test5"(int %A, int %Bok, int %Cok) {
34         %D = sub int %Bok, %Cok
35         %E = sub int %A, %D
36         ret int %E
37 }