1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 define i1 @uge_zext(i8 %x, i16 %y) {
5 ; CHECK-LABEL: @uge_zext(
7 ; CHECK-NEXT: [[X_EXT:%.*]] = zext i8 [[X:%.*]] to i16
8 ; CHECK-NEXT: [[C_1:%.*]] = icmp uge i16 [[X_EXT]], [[Y:%.*]]
9 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
11 ; CHECK-NEXT: [[C_2:%.*]] = icmp uge i16 [[X_EXT]], 10
12 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, [[C_2]]
13 ; CHECK-NEXT: [[C_3:%.*]] = icmp uge i16 [[Y]], [[X_EXT]]
14 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[C_3]]
15 ; CHECK-NEXT: [[C_4:%.*]] = icmp uge i16 10, [[X_EXT]]
16 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_4]]
17 ; CHECK-NEXT: ret i1 [[R_3]]
19 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 true, false
20 ; CHECK-NEXT: [[C_5:%.*]] = icmp uge i16 [[X_EXT]], 10
21 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
22 ; CHECK-NEXT: [[C_6:%.*]] = icmp uge i16 10, [[X_EXT]]
23 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_6]]
24 ; CHECK-NEXT: ret i1 [[R_6]]
27 %x.ext = zext i8 %x to i16
28 %c.1 = icmp uge i16 %x.ext, %y
29 br i1 %c.1, label %bb1, label %bb2
32 %t.1 = icmp uge i16 %x.ext, %y
33 %c.2 = icmp uge i16 %x.ext, 10
34 %r.1 = xor i1 %t.1, %c.2
35 %c.3 = icmp uge i16 %y, %x.ext
36 %r.2 = xor i1 %r.1, %c.3
37 %c.4 = icmp uge i16 10, %x.ext
38 %r.3 = xor i1 %r.2, %c.4
42 %t.2 = icmp uge i16 %y, %x.ext
43 %f.1 = icmp uge i16 %x.ext, %y
44 %r.4 = xor i1 %t.2, %f.1
45 %c.5 = icmp uge i16 %x.ext, 10
46 %r.5 = xor i1 %r.4, %c.5
47 %c.6 = icmp uge i16 10, %x.ext
48 %r.6 = xor i1 %r.5, %c.6
52 define i1 @uge_compare_short_and_extended(i8 %x, i8 %y) {
53 ; CHECK-LABEL: @uge_compare_short_and_extended(
55 ; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
56 ; CHECK-NEXT: [[X_EXT:%.*]] = zext i8 [[X]] to i16
57 ; CHECK-NEXT: [[Y_EXT:%.*]] = zext i8 [[Y]] to i16
58 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
60 ; CHECK-NEXT: [[C_2:%.*]] = icmp uge i16 [[X_EXT]], 10
61 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, [[C_2]]
62 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i16 [[Y_EXT]], [[X_EXT]]
63 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[C_3]]
64 ; CHECK-NEXT: [[C_4:%.*]] = icmp uge i16 10, [[X_EXT]]
65 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_4]]
66 ; CHECK-NEXT: ret i1 [[R_3]]
68 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 true, false
69 ; CHECK-NEXT: [[C_5:%.*]] = icmp uge i16 [[X_EXT]], 10
70 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
71 ; CHECK-NEXT: [[C_6:%.*]] = icmp uge i16 10, [[X_EXT]]
72 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_6]]
73 ; CHECK-NEXT: ret i1 [[R_6]]
76 %c.1 = icmp uge i8 %x, %y
77 %x.ext = zext i8 %x to i16
78 %y.ext = zext i8 %y to i16
79 br i1 %c.1, label %bb1, label %bb2
82 %t.1 = icmp uge i16 %x.ext, %y.ext
83 %c.2 = icmp uge i16 %x.ext, 10
84 %r.1 = xor i1 %t.1, %c.2
85 %c.3 = icmp sge i16 %y.ext, %x.ext
86 %r.2 = xor i1 %r.1, %c.3
87 %c.4 = icmp uge i16 10, %x.ext
88 %r.3 = xor i1 %r.2, %c.4
92 %t.2 = icmp uge i16 %y.ext, %x.ext
93 %f.1 = icmp uge i16 %x.ext, %y.ext
94 %r.4 = xor i1 %t.2, %f.1
95 %c.5 = icmp uge i16 %x.ext, 10
96 %r.5 = xor i1 %r.4, %c.5
97 %c.6 = icmp uge i16 10, %x.ext
98 %r.6 = xor i1 %r.5, %c.6
102 define i1 @uge_zext_add(i8 %x, i16 %y) {
103 ; CHECK-LABEL: @uge_zext_add(
105 ; CHECK-NEXT: [[X_ADD_1:%.*]] = add nuw nsw i8 [[X:%.*]], 1
106 ; CHECK-NEXT: [[X_ADD_1_EXT:%.*]] = zext i8 [[X_ADD_1]] to i16
107 ; CHECK-NEXT: [[X_EXT:%.*]] = zext i8 [[X]] to i16
108 ; CHECK-NEXT: [[C_1:%.*]] = icmp uge i16 [[X_ADD_1_EXT]], [[Y:%.*]]
109 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
111 ; CHECK-NEXT: [[T_1:%.*]] = icmp uge i16 [[X_EXT]], [[Y]]
112 ; CHECK-NEXT: [[C_2:%.*]] = icmp uge i16 [[X_EXT]], 10
113 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 [[T_1]], [[C_2]]
114 ; CHECK-NEXT: [[C_3:%.*]] = icmp uge i16 [[Y]], [[X_EXT]]
115 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[C_3]]
116 ; CHECK-NEXT: [[C_4:%.*]] = icmp uge i16 10, [[X_EXT]]
117 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_4]]
118 ; CHECK-NEXT: ret i1 [[R_3]]
120 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 true, false
121 ; CHECK-NEXT: [[C_5:%.*]] = icmp uge i16 [[X_EXT]], 10
122 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
123 ; CHECK-NEXT: [[C_6:%.*]] = icmp uge i16 10, [[X_EXT]]
124 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_6]]
125 ; CHECK-NEXT: ret i1 [[R_6]]
128 %x.add.1 = add nuw nsw i8 %x, 1
129 %x.add.1.ext = zext i8 %x.add.1 to i16
130 %x.ext = zext i8 %x to i16
131 %c.1 = icmp uge i16 %x.add.1.ext, %y
132 br i1 %c.1, label %bb1, label %bb2
135 %t.1 = icmp uge i16 %x.ext, %y
136 %c.2 = icmp uge i16 %x.ext, 10
137 %r.1 = xor i1 %t.1, %c.2
138 %c.3 = icmp uge i16 %y, %x.ext
139 %r.2 = xor i1 %r.1, %c.3
140 %c.4 = icmp uge i16 10, %x.ext
141 %r.3 = xor i1 %r.2, %c.4
145 %t.2 = icmp uge i16 %y, %x.ext
146 %f.1 = icmp uge i16 %x.ext, %y
147 %r.4 = xor i1 %t.2, %f.1
148 %c.5 = icmp uge i16 %x.ext, 10
149 %r.5 = xor i1 %r.4, %c.5
150 %c.6 = icmp uge i16 10, %x.ext
151 %r.6 = xor i1 %r.5, %c.6
155 define i1 @sge_zext(i8 %x, i16 %y) {
156 ; CHECK-LABEL: @sge_zext(
158 ; CHECK-NEXT: [[X_EXT:%.*]] = zext i8 [[X:%.*]] to i16
159 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i16 [[X_EXT]], [[Y:%.*]]
160 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
162 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i16 [[X_EXT]], 10
163 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 true, [[C_2]]
164 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i16 [[Y]], [[X_EXT]]
165 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[C_3]]
166 ; CHECK-NEXT: [[C_4:%.*]] = icmp sge i16 10, [[X_EXT]]
167 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_4]]
168 ; CHECK-NEXT: ret i1 [[R_3]]
170 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 true, false
171 ; CHECK-NEXT: [[C_5:%.*]] = icmp sge i16 [[X_EXT]], 10
172 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
173 ; CHECK-NEXT: [[C_6:%.*]] = icmp sge i16 10, [[X_EXT]]
174 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_6]]
175 ; CHECK-NEXT: ret i1 [[R_6]]
178 %x.ext = zext i8 %x to i16
179 %c.1 = icmp sge i16 %x.ext, %y
180 br i1 %c.1, label %bb1, label %bb2
183 %t.1 = icmp sge i16 %x.ext, %y
184 %c.2 = icmp sge i16 %x.ext, 10
185 %r.1 = xor i1 %t.1, %c.2
186 %c.3 = icmp sge i16 %y, %x.ext
187 %r.2 = xor i1 %r.1, %c.3
188 %c.4 = icmp sge i16 10, %x.ext
189 %r.3 = xor i1 %r.2, %c.4
193 %t.2 = icmp sge i16 %y, %x.ext
194 %f.1 = icmp sge i16 %x.ext, %y
195 %r.4 = xor i1 %t.2, %f.1
196 %c.5 = icmp sge i16 %x.ext, 10
197 %r.5 = xor i1 %r.4, %c.5
198 %c.6 = icmp sge i16 10, %x.ext
199 %r.6 = xor i1 %r.5, %c.6
204 define i1 @sge_compare_short_and_extended(i8 %x, i8 %y) {
205 ; CHECK-LABEL: @sge_compare_short_and_extended(
207 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
208 ; CHECK-NEXT: [[X_EXT:%.*]] = zext i8 [[X]] to i16
209 ; CHECK-NEXT: [[Y_EXT:%.*]] = zext i8 [[Y]] to i16
210 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
212 ; CHECK-NEXT: [[T_1:%.*]] = icmp sge i16 [[X_EXT]], [[Y_EXT]]
213 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i16 [[X_EXT]], 10
214 ; CHECK-NEXT: [[R_1:%.*]] = xor i1 [[T_1]], [[C_2]]
215 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i16 [[Y_EXT]], [[X_EXT]]
216 ; CHECK-NEXT: [[R_2:%.*]] = xor i1 [[R_1]], [[C_3]]
217 ; CHECK-NEXT: [[C_4:%.*]] = icmp sge i16 10, [[X_EXT]]
218 ; CHECK-NEXT: [[R_3:%.*]] = xor i1 [[R_2]], [[C_4]]
219 ; CHECK-NEXT: ret i1 [[R_3]]
221 ; CHECK-NEXT: [[T_2:%.*]] = icmp sge i16 [[Y_EXT]], [[X_EXT]]
222 ; CHECK-NEXT: [[F_1:%.*]] = icmp sge i16 [[X_EXT]], [[Y_EXT]]
223 ; CHECK-NEXT: [[R_4:%.*]] = xor i1 [[T_2]], [[F_1]]
224 ; CHECK-NEXT: [[C_5:%.*]] = icmp sge i16 [[X_EXT]], 10
225 ; CHECK-NEXT: [[R_5:%.*]] = xor i1 [[R_4]], [[C_5]]
226 ; CHECK-NEXT: [[C_6:%.*]] = icmp sge i16 10, [[X_EXT]]
227 ; CHECK-NEXT: [[R_6:%.*]] = xor i1 [[R_5]], [[C_6]]
228 ; CHECK-NEXT: ret i1 [[R_6]]
231 %c.1 = icmp sge i8 %x, %y
232 %x.ext = zext i8 %x to i16
233 %y.ext = zext i8 %y to i16
234 br i1 %c.1, label %bb1, label %bb2
237 %t.1 = icmp sge i16 %x.ext, %y.ext
238 %c.2 = icmp sge i16 %x.ext, 10
239 %r.1 = xor i1 %t.1, %c.2
240 %c.3 = icmp sge i16 %y.ext, %x.ext
241 %r.2 = xor i1 %r.1, %c.3
242 %c.4 = icmp sge i16 10, %x.ext
243 %r.3 = xor i1 %r.2, %c.4
247 %t.2 = icmp sge i16 %y.ext, %x.ext
248 %f.1 = icmp sge i16 %x.ext, %y.ext
249 %r.4 = xor i1 %t.2, %f.1
250 %c.5 = icmp sge i16 %x.ext, 10
251 %r.5 = xor i1 %r.4, %c.5
252 %c.6 = icmp sge i16 10, %x.ext
253 %r.6 = xor i1 %r.5, %c.6
257 define i1 @test_pr58009_const_zext() {
258 ; CHECK-LABEL: @test_pr58009_const_zext(
260 ; CHECK-NEXT: [[EXT_T_1:%.*]] = zext i1 true to i16
261 ; CHECK-NEXT: [[EXT_T_2:%.*]] = zext i1 true to i16
262 ; CHECK-NEXT: [[RES_1:%.*]] = xor i1 true, false
263 ; CHECK-NEXT: [[EXT_F_1:%.*]] = zext i1 false to i16
264 ; CHECK-NEXT: [[EXT_F_2:%.*]] = zext i1 false to i16
265 ; CHECK-NEXT: [[RES_2:%.*]] = xor i1 [[RES_1]], true
266 ; CHECK-NEXT: [[RES_3:%.*]] = xor i1 [[RES_2]], false
267 ; CHECK-NEXT: [[T_3:%.*]] = icmp ult i16 [[EXT_F_1]], [[EXT_T_2]]
268 ; CHECK-NEXT: [[F_3:%.*]] = icmp ugt i16 [[EXT_F_1]], [[EXT_T_2]]
269 ; CHECK-NEXT: [[RES_4:%.*]] = xor i1 [[RES_3]], [[T_3]]
270 ; CHECK-NEXT: [[RES_5:%.*]] = xor i1 [[RES_4]], [[F_3]]
271 ; CHECK-NEXT: ret i1 [[RES_5]]
274 %ext.t.1 = zext i1 true to i16
275 %ext.t.2 = zext i1 true to i16
276 %t.1 = icmp uge i16 %ext.t.1, %ext.t.2
277 %f.1 = icmp ugt i16 %ext.t.1, %ext.t.2
278 %res.1 = xor i1 %t.1, %f.1
280 %ext.f.1 = zext i1 false to i16
281 %ext.f.2 = zext i1 false to i16
282 %t.2 = icmp uge i16 %ext.f.1, %ext.f.2
283 %f.2 = icmp ugt i16 %ext.f.1, %ext.f.2
284 %res.2 = xor i1 %res.1, %t.2
285 %res.3 = xor i1 %res.2, %f.2
287 %t.3 = icmp ult i16 %ext.f.1, %ext.t.2
288 %f.3 = icmp ugt i16 %ext.f.1, %ext.t.2
289 %res.4 = xor i1 %res.3, %t.3
290 %res.5 = xor i1 %res.4, %f.3