1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instcombine < %s -S | FileCheck %s
4 define i8 @phi_ugt_high_bits(i8 %x) {
5 ; CHECK-LABEL: @phi_ugt_high_bits(
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], -65
8 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
10 ; CHECK-NEXT: ret i8 64
12 ; CHECK-NEXT: br label [[T]]
15 %cmp = icmp ugt i8 %x, 191
16 br i1 %cmp, label %T, label %F
18 %v = phi i8 [ %x, %entry], [-1, %F]
25 define i8 @phi_ult_low_bits(i8 %x) {
26 ; CHECK-LABEL: @phi_ult_low_bits(
28 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], -64
29 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
31 ; CHECK-NEXT: br label [[F]]
33 ; CHECK-NEXT: ret i8 64
36 %cmp = icmp ult i8 %x, 192
37 br i1 %cmp, label %T, label %F
41 %v = phi i8 [ %x, %entry], [-1, %T]
46 define i8 @phi_ugt_high_bits_fail(i8 %x) {
47 ; CHECK-LABEL: @phi_ugt_high_bits_fail(
49 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], -66
50 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
52 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
53 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
54 ; CHECK-NEXT: ret i8 [[R]]
56 ; CHECK-NEXT: br label [[T]]
59 %cmp = icmp ugt i8 %x, 190
60 br i1 %cmp, label %T, label %F
62 %v = phi i8 [ %x, %entry], [-1, %F]
69 define i8 @phi_uge_high_bits(i8 %x) {
70 ; CHECK-LABEL: @phi_uge_high_bits(
72 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], -65
73 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
75 ; CHECK-NEXT: ret i8 64
77 ; CHECK-NEXT: br label [[T]]
80 %cmp = icmp uge i8 %x, 192
81 br i1 %cmp, label %T, label %F
83 %v = phi i8 [ %x, %entry], [-1, %F]
90 define i8 @phi_uge_high_bits_fail(i8 %x) {
91 ; CHECK-LABEL: @phi_uge_high_bits_fail(
93 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], 5
94 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
96 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
97 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
98 ; CHECK-NEXT: ret i8 [[R]]
100 ; CHECK-NEXT: br label [[T]]
103 %cmp = icmp ugt i8 %x, 5
104 br i1 %cmp, label %T, label %F
106 %v = phi i8 [ %x, %entry], [-1, %F]
113 define i8 @phi_sge_high_bits(i8 %x) {
114 ; CHECK-LABEL: @phi_sge_high_bits(
116 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 95
117 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
119 ; CHECK-NEXT: ret i8 96
121 ; CHECK-NEXT: br label [[T]]
124 %cmp = icmp sge i8 %x, 96
125 br i1 %cmp, label %T, label %F
127 %v = phi i8 [ %x, %entry], [-1, %F]
134 define i8 @phi_sge_high_bits_fail(i8 %x) {
135 ; CHECK-LABEL: @phi_sge_high_bits_fail(
137 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -2
138 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
140 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
141 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
142 ; CHECK-NEXT: ret i8 [[R]]
144 ; CHECK-NEXT: br label [[T]]
147 %cmp = icmp sge i8 %x, -1
148 br i1 %cmp, label %T, label %F
150 %v = phi i8 [ %x, %entry], [-1, %F]
157 define i8 @phi_sgt_high_bits(i8 %x) {
158 ; CHECK-LABEL: @phi_sgt_high_bits(
160 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], -1
161 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
163 ; CHECK-NEXT: ret i8 0
165 ; CHECK-NEXT: br label [[T]]
168 %cmp = icmp sgt i8 %x, -1
169 br i1 %cmp, label %T, label %F
171 %v = phi i8 [ %x, %entry], [0, %F]
178 define i8 @phi_sgt_high_bits2(i8 %x) {
179 ; CHECK-LABEL: @phi_sgt_high_bits2(
181 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 63
182 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
184 ; CHECK-NEXT: ret i8 64
186 ; CHECK-NEXT: br label [[T]]
189 %cmp = icmp sgt i8 %x, 63
190 br i1 %cmp, label %T, label %F
192 %v = phi i8 [ %x, %entry], [-1, %F]
199 define i8 @phi_sgt_high_bits_fail(i8 %x) {
200 ; CHECK-LABEL: @phi_sgt_high_bits_fail(
202 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], 62
203 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
205 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
206 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
207 ; CHECK-NEXT: ret i8 [[R]]
209 ; CHECK-NEXT: br label [[T]]
212 %cmp = icmp sgt i8 %x, 62
213 br i1 %cmp, label %T, label %F
215 %v = phi i8 [ %x, %entry], [-1, %F]
222 define i8 @phi_slt_high_bits(i8 %x) {
223 ; CHECK-LABEL: @phi_slt_high_bits(
225 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 0
226 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
228 ; CHECK-NEXT: ret i8 -128
230 ; CHECK-NEXT: br label [[T]]
233 %cmp = icmp slt i8 %x, 0
234 br i1 %cmp, label %T, label %F
236 %v = phi i8 [ %x, %entry], [-1, %F]
243 define i8 @phi_slt_high_bits2(i8 %x) {
244 ; CHECK-LABEL: @phi_slt_high_bits2(
246 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -64
247 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
249 ; CHECK-NEXT: ret i8 0
251 ; CHECK-NEXT: br label [[T]]
254 %cmp = icmp slt i8 %x, -64
255 br i1 %cmp, label %T, label %F
257 %v = phi i8 [ %x, %entry], [0, %F]
264 define i8 @phi_slt_high_bits_fail(i8 %x) {
265 ; CHECK-LABEL: @phi_slt_high_bits_fail(
267 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -63
268 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
270 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ 0, [[F]] ]
271 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
272 ; CHECK-NEXT: ret i8 [[R]]
274 ; CHECK-NEXT: br label [[T]]
277 %cmp = icmp slt i8 %x, -63
278 br i1 %cmp, label %T, label %F
280 %v = phi i8 [ %x, %entry], [0, %F]
287 define i8 @phi_sle_high_bits(i8 %x) {
288 ; CHECK-LABEL: @phi_sle_high_bits(
290 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -64
291 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
293 ; CHECK-NEXT: ret i8 0
295 ; CHECK-NEXT: br label [[T]]
298 %cmp = icmp sle i8 %x, -65
299 br i1 %cmp, label %T, label %F
301 %v = phi i8 [ %x, %entry], [0, %F]
308 define i8 @phi_sle_low_bits(i8 %x) {
309 ; CHECK-LABEL: @phi_sle_low_bits(
311 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 65
312 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
314 ; CHECK-NEXT: br label [[F]]
316 ; CHECK-NEXT: ret i8 64
319 %cmp = icmp sle i8 %x, 64
320 br i1 %cmp, label %T, label %F
324 %v = phi i8 [ %x, %entry], [-1, %T]
329 define i8 @phi_sle_high_bits_fail(i8 %x) {
330 ; CHECK-LABEL: @phi_sle_high_bits_fail(
332 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], 1
333 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
335 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
336 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], -128
337 ; CHECK-NEXT: ret i8 [[R]]
339 ; CHECK-NEXT: br label [[T]]
342 %cmp = icmp sle i8 %x, 0
343 br i1 %cmp, label %T, label %F
345 %v = phi i8 [ %x, %entry], [-1, %F]
352 define i8 @phi_sle_high_bits_fail2(i8 %x) {
353 ; CHECK-LABEL: @phi_sle_high_bits_fail2(
355 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], -63
356 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
358 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
359 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 64
360 ; CHECK-NEXT: ret i8 [[R]]
362 ; CHECK-NEXT: br label [[T]]
365 %cmp = icmp sle i8 %x, -64
366 br i1 %cmp, label %T, label %F
368 %v = phi i8 [ %x, %entry], [-1, %F]
375 define i8 @phi_ugt_high_bits_and_known(i8 %xx) {
376 ; CHECK-LABEL: @phi_ugt_high_bits_and_known(
378 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[XX:%.*]], -65
379 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
381 ; CHECK-NEXT: ret i8 65
383 ; CHECK-NEXT: br label [[T]]
387 %cmp = icmp ugt i8 %x, 191
388 br i1 %cmp, label %T, label %F
390 %v = phi i8 [ %x, %entry], [-1, %F]
397 define i8 @phi_ugt_high_bits_and_known_todo_high_depths(i8 %xx, i8 %y, i8 %z) {
398 ; CHECK-LABEL: @phi_ugt_high_bits_and_known_todo_high_depths(
400 ; CHECK-NEXT: [[YY:%.*]] = and i8 [[Y:%.*]], -2
401 ; CHECK-NEXT: [[XXX:%.*]] = and i8 [[YY]], [[XX:%.*]]
402 ; CHECK-NEXT: [[ZZ:%.*]] = or i8 [[Z:%.*]], 1
403 ; CHECK-NEXT: [[X:%.*]] = add i8 [[XXX]], [[ZZ]]
404 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X]], -65
405 ; CHECK-NEXT: br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]]
407 ; CHECK-NEXT: [[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
408 ; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 65
409 ; CHECK-NEXT: ret i8 [[R]]
411 ; CHECK-NEXT: br label [[T]]
415 %xxx = and i8 %xx, %yy
417 %x = add i8 %xxx, %zz
418 %cmp = icmp ugt i8 %x, 191
419 br i1 %cmp, label %T, label %F
421 %v = phi i8 [ %x, %entry], [-1, %F]