blob: 9ade443c0cbb9dbb15dc2a49a81b90dc44df6d72 [file] [log] [blame]
Chris Lattner6022ad02002-05-06 05:51:26 +00001; This test makes sure that these instructions are properly eliminated.
2;
3
Misha Brukmanedf4bab2003-09-16 15:29:54 +00004; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep set
Chris Lattner6022ad02002-05-06 05:51:26 +00005
Chris Lattnerce59a3d2002-05-09 19:52:36 +00006%X = uninitialized global int
Chris Lattner6022ad02002-05-06 05:51:26 +00007
Chris Lattnerd3ce33c2003-06-04 04:47:40 +00008bool %test1(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +00009 %B = seteq int %A, %A
Chris Lattnerce59a3d2002-05-09 19:52:36 +000010 %C = seteq int* %X, null ; Never true
11 %D = and bool %B, %C
12 ret bool %D
Chris Lattner6022ad02002-05-06 05:51:26 +000013}
14
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000015bool %test2(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000016 %B = setne int %A, %A
Chris Lattnerce59a3d2002-05-09 19:52:36 +000017 %C = setne int* %X, null ; Never false
18 %D = or bool %B, %C
19 ret bool %D
Chris Lattner6022ad02002-05-06 05:51:26 +000020}
21
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000022bool %test3(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000023 %B = setlt int %A, %A
24 ret bool %B
25}
26
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000027bool %test4(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000028 %B = setgt int %A, %A
29 ret bool %B
30}
31
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000032bool %test5(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000033 %B = setle int %A, %A
34 ret bool %B
35}
36
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000037bool %test6(int %A) {
Chris Lattner6022ad02002-05-06 05:51:26 +000038 %B = setge int %A, %A
39 ret bool %B
40}
Chris Lattnerff61e352002-08-03 20:24:58 +000041
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000042bool %test7(uint %A) {
Chris Lattnerff61e352002-08-03 20:24:58 +000043 %B = setge uint %A, 0 ; true
44 ret bool %B
45}
46
Chris Lattnerd3ce33c2003-06-04 04:47:40 +000047bool %test8(uint %A) {
Chris Lattnerff61e352002-08-03 20:24:58 +000048 %B = setlt uint %A, 0 ; false
49 ret bool %B
50}
Chris Lattnerb86ab652002-08-09 23:34:18 +000051
52;; test operations on boolean values these should all be eliminated$a
53bool %test9(bool %A) {
54 %B = setlt bool %A, false ; false
55 ret bool %B
56}
57bool %test10(bool %A) {
58 %B = setgt bool %A, true ; false
59 ret bool %B
60}
61bool %test11(bool %A) {
62 %B = setle bool %A, true ; true
63 ret bool %B
64}
65bool %test12(bool %A) {
66 %B = setge bool %A, false ; true
67 ret bool %B
68}
69bool %test13(bool %A, bool %B) {
70 %C = setge bool %A, %B ; A | ~B
71 ret bool %C
72}
73bool %test14(bool %A, bool %B) {
74 %C = seteq bool %A, %B ; ~(A ^ B)
75 ret bool %C
76}
77
Chris Lattnera4f252d2003-07-23 17:01:18 +000078bool %test16(uint %A) {
79 %B = and uint %A, 5
80 %C = seteq uint %B, 8 ; Is never true
81 ret bool %C
82}
83
84bool %test17(ubyte %A) {
85 %B = or ubyte %A, 1
86 %C = seteq ubyte %B, 2 ; Always false
87 ret bool %C
88}
89
Chris Lattner5e0ab5c2004-09-29 05:06:12 +000090bool %test18(bool %C, int %a) {
91entry:
92 br bool %C, label %endif, label %else
93
94else:
95 br label %endif
96
97endif:
98 %b.0 = phi int [ 0, %entry ], [ 1, %else ]
99 %tmp.4 = setlt int %b.0, 123
100 ret bool %tmp.4
101}
102