760e14d1e29aefa62f7cbfc3f0246998dc64e49c
[oota-llvm.git] / test / Transforms / InstCombine / set.ll
1 ; This test makes sure that these instructions are properly eliminated.
2 ;
3
4 ; RUN: as < %s | opt -instcombine | dis | grep-not set
5
6 %X = uninitialized global int
7
8 bool %test1(int %A) {
9         %B = seteq int %A, %A
10         %C = seteq int* %X, null   ; Never true
11         %D = and bool %B, %C
12         ret bool %D
13 }
14
15 bool %test2(int %A) {
16         %B = setne int %A, %A
17         %C = setne int* %X, null   ; Never false
18         %D = or bool %B, %C
19         ret bool %D
20 }
21
22 bool %test3(int %A) {
23         %B = setlt int %A, %A
24         ret bool %B
25 }
26
27 bool %test4(int %A) {
28         %B = setgt int %A, %A
29         ret bool %B
30 }
31
32 bool %test5(int %A) {
33         %B = setle int %A, %A
34         ret bool %B
35 }
36
37 bool %test6(int %A) {
38         %B = setge int %A, %A
39         ret bool %B
40 }
41
42 bool %test7(uint %A) {
43         %B = setge uint %A, 0  ; true
44         ret bool %B
45 }
46
47 bool %test8(uint %A) {
48         %B = setlt uint %A, 0  ; false
49         ret bool %B
50 }
51
52 ;; test operations on boolean values these should all be eliminated$a
53 bool %test9(bool %A) {
54         %B = setlt bool %A, false ; false
55         ret bool %B
56 }
57 bool %test10(bool %A) {
58         %B = setgt bool %A, true  ; false
59         ret bool %B
60 }
61 bool %test11(bool %A) {
62         %B = setle bool %A, true ; true
63         ret bool %B
64 }
65 bool %test12(bool %A) {
66         %B = setge bool %A, false  ; true
67         ret bool %B
68 }
69 bool %test13(bool %A, bool %B) {
70         %C = setge bool %A, %B       ; A | ~B
71         ret bool %C
72 }
73 bool %test14(bool %A, bool %B) {
74         %C = seteq bool %A, %B  ; ~(A ^ B)
75         ret bool %C
76 }
77
78 ; These instructions can be turned into cast-to-bool
79 bool %test15(sbyte %A, short %A, int %A, long %A) {
80         %B1 = setne sbyte %A, 0
81         %B2 = seteq short %A, 0
82         %B3 = setne int %A, 0
83         %B4 = seteq long %A, 0
84         %C1 = or bool %B1, %B2
85         %C2 = or bool %B3, %B4
86         %D = or bool %C1, %C2
87         ret bool %D
88 }