1 ; This test makes sure that these instructions are properly eliminated.
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
9 int %test1(int %A, int %B) {
10 %C = select bool false, int %A, int %B
14 int %test2(int %A, int %B) {
15 %C = select bool true, int %A, int %B
19 int %test3(bool %C, int %I) {
20 %V = select bool %C, int %I, int %I ; V = I
24 bool %test4(bool %C) {
25 %V = select bool %C, bool true, bool false ; V = C
29 bool %test5(bool %C) {
30 %V = select bool %C, bool false, bool true ; V = !C
35 %V = select bool %C, int 1, int 0 ; V = cast C to int
39 bool %test7(bool %C, bool %X) {
40 %R = select bool %C, bool true, bool %X ; R = or C, X
44 bool %test8(bool %C, bool %X) {
45 %R = select bool %C, bool %X, bool false ; R = and C, X
49 bool %test9(bool %C, bool %X) {
50 %R = select bool %C, bool false, bool %X ; R = and !C, X
54 bool %test10(bool %C, bool %X) {
55 %R = select bool %C, bool %X, bool true ; R = or !C, X
61 %R = select bool %C, int 0, int 1
65 int %test12(bool %cond, int %a) {
67 %c = select bool %cond, int %b, int %a
71 int %test12a(bool %cond, int %a) {
72 %b = shr int %a, ubyte 1
73 %c = select bool %cond, int %b, int %a
77 int %test12b(bool %cond, int %a) {
78 %b = shr int %a, ubyte 1
79 %c = select bool %cond, int %a, int %b
83 int %test13(int %a, int %b) {
85 %V = select bool %C, int %a, int %b
89 int %test13a(int %a, int %b) {
91 %V = select bool %C, int %a, int %b
95 int %test13b(int %a, int %b) {
97 %V = select bool %C, int %b, int %a
101 bool %test14a(bool %C, int %X) {
102 %V = select bool %C, int %X, int 0
103 %R = setlt int %V, 1 ; (X < 1) | !C
107 bool %test14b(bool %C, int %X) {
108 %V = select bool %C, int 0, int %X
109 %R = setlt int %V, 1 ; (X < 1) | C
113 int %test15a(int %X) { ;; Code sequence for (X & 16) ? 16 : 0
115 %t2 = seteq int %t1, 0
116 %t3 = select bool %t2, int 0, int 16 ;; X & 16
120 int %test15b(int %X) { ;; Code sequence for (X & 32) ? 0 : 24
122 %t2 = seteq int %t1, 0
123 %t3 = select bool %t2, int 32, int 0 ;; ~X & 32
127 int %test15c(int %X) { ;; Alternate code sequence for (X & 16) ? 16 : 0
129 %t2 = seteq int %t1, 16
130 %t3 = select bool %t2, int 16, int 0 ;; X & 16
134 int %test15d(int %X) { ;; Alternate code sequence for (X & 16) ? 16 : 0
136 %t2 = setne int %t1, 0
137 %t3 = select bool %t2, int 16, int 0 ;; X & 16
141 int %test16(bool %C, int* %P) {
142 %P2 = select bool %C, int* %P, int* null
147 bool %test17(int* %X, bool %C) {
148 %R = select bool %C, int* %X, int* null
149 %RV = seteq int* %R, null
153 int %test18(int %X, int %Y, bool %C) {
154 %R = select bool %C, int %X, int 0
155 %V = div int %Y, %R ; div Y,X
159 int %test19(uint %x) {
160 %tmp = setgt uint %x, 2147483647
161 %retval = select bool %tmp, int -1, int 0
165 int %test20(int %x) {
166 %tmp = setlt int %x, 0
167 %retval = select bool %tmp, int -1, int 0
171 long %test21(int %x) {
172 %tmp = setlt int %x, 0
173 %retval = select bool %tmp, long -1, long 0
177 short %test22(int %x) {
178 %tmp = setlt int %x, 0
179 %retval = select bool %tmp, short -1, short 0