1 ; This test makes sure that these instructions are properly eliminated.
4 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep select
8 int %test1(int %A, int %B) {
9 %C = select bool false, int %A, int %B
13 int %test2(int %A, int %B) {
14 %C = select bool true, int %A, int %B
18 int %test3(bool %C, int %I) {
19 %V = select bool %C, int %I, int %I ; V = I
23 bool %test4(bool %C) {
24 %V = select bool %C, bool true, bool false ; V = C
28 bool %test5(bool %C) {
29 %V = select bool %C, bool false, bool true ; V = !C
34 %V = select bool %C, int 1, int 0 ; V = cast C to int
38 bool %test7(bool %C, bool %X) {
39 %R = select bool %C, bool true, bool %X ; R = or C, X
43 bool %test8(bool %C, bool %X) {
44 %R = select bool %C, bool %X, bool false ; R = and C, X
48 bool %test9(bool %C, bool %X) {
49 %R = select bool %C, bool false, bool %X ; R = and !C, X
53 bool %test10(bool %C, bool %X) {
54 %R = select bool %C, bool %X, bool true ; R = or !C, X
60 %R = select bool %C, int 0, int 1
64 int %test12(bool %cond, int %a) {
66 %c = select bool %cond, int %b, int %a
70 int %test12a(bool %cond, int %a) {
71 %b = shr int %a, ubyte 1
72 %c = select bool %cond, int %b, int %a
76 int %test12b(bool %cond, int %a) {
77 %b = shr int %a, ubyte 1
78 %c = select bool %cond, int %a, int %b
82 int %test13(int %a, int %b) {
84 %V = select bool %C, int %a, int %b
88 int %test13a(int %a, int %b) {
90 %V = select bool %C, int %a, int %b
94 int %test13b(int %a, int %b) {
96 %V = select bool %C, int %b, int %a
100 bool %test14a(bool %C, int %X) {
101 %V = select bool %C, int %X, int 0
102 %R = setlt int %V, 1 ; (X < 1) | !C
106 bool %test14b(bool %C, int %X) {
107 %V = select bool %C, int 0, int %X
108 %R = setlt int %V, 1 ; (X < 1) | C
112 int %test15a(int %X) { ;; Code sequence for (X & 16) ? 16 : 0
114 %t2 = seteq int %t1, 0
115 %t3 = select bool %t2, int 0, int 16 ;; X & 16
119 int %test15b(int %X) { ;; Code sequence for (X & 32) ? 0 : 24
121 %t2 = seteq int %t1, 0
122 %t3 = select bool %t2, int 32, int 0 ;; ~X & 32
126 int %test15c(int %X) { ;; Alternate code sequence for (X & 16) ? 16 : 0
128 %t2 = seteq int %t1, 16
129 %t3 = select bool %t2, int 16, int 0 ;; X & 16
133 int %test15d(int %X) { ;; Alternate code sequence for (X & 16) ? 16 : 0
135 %t2 = setne int %t1, 0
136 %t3 = select bool %t2, int 16, int 0 ;; X & 16
140 int %test16(bool %C, int* %P) {
141 %P2 = select bool %C, int* %P, int* null
146 bool %test17(int* %X, bool %C) {
147 %R = select bool %C, int* %X, int* null
148 %RV = seteq int* %R, null
152 int %test18(int %X, int %Y, bool %C) {
153 %R = select bool %C, int %X, int 0
154 %V = div int %Y, %R ; div Y,X
158 int %test19(uint %x) {
159 %tmp = setgt uint %x, 2147483647
160 %retval = select bool %tmp, int -1, int 0
164 int %test20(int %x) {
165 %tmp = setlt int %x, 0
166 %retval = select bool %tmp, int -1, int 0
170 long %test21(int %x) {
171 %tmp = setlt int %x, 0
172 %retval = select bool %tmp, long -1, long 0
176 short %test22(int %x) {
177 %tmp = setlt int %x, 0
178 %retval = select bool %tmp, short -1, short 0
182 bool %test23(bool %a, bool %b) {
183 %c = select bool %a, bool %b, bool %a
187 bool %test24(bool %a, bool %b) {
188 %c = select bool %a, bool %a, bool %b