1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; Test an already canonical branch to make sure we don't flip those.
5 define i32 @eq(i32 %X, i32 %Y) {
7 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
8 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !0
10 ; CHECK-NEXT: ret i32 12
12 ; CHECK-NEXT: ret i32 123
14 %C = icmp eq i32 %X, %Y
15 br i1 %C, label %T, label %F, !prof !0
22 define i32 @ne(i32 %X, i32 %Y) {
24 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
25 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !1
27 ; CHECK-NEXT: ret i32 12
29 ; CHECK-NEXT: ret i32 123
31 %C = icmp ne i32 %X, %Y
32 br i1 %C, label %T, label %F, !prof !1
39 define i32 @ugt(i32 %X, i32 %Y) {
41 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
42 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !2
44 ; CHECK-NEXT: ret i32 12
46 ; CHECK-NEXT: ret i32 123
48 %C = icmp ugt i32 %X, %Y
49 br i1 %C, label %T, label %F, !prof !2
56 define i32 @uge(i32 %X, i32 %Y) {
58 ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]]
59 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !3
61 ; CHECK-NEXT: ret i32 12
63 ; CHECK-NEXT: ret i32 123
65 %C = icmp uge i32 %X, %Y
66 br i1 %C, label %T, label %F, !prof !3
73 define i32 @ult(i32 %X, i32 %Y) {
75 ; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[X:%.*]], [[Y:%.*]]
76 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !4
78 ; CHECK-NEXT: ret i32 12
80 ; CHECK-NEXT: ret i32 123
82 %C = icmp ult i32 %X, %Y
83 br i1 %C, label %T, label %F, !prof !4
90 define i32 @ule(i32 %X, i32 %Y) {
92 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
93 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !5
95 ; CHECK-NEXT: ret i32 12
97 ; CHECK-NEXT: ret i32 123
99 %C = icmp ule i32 %X, %Y
100 br i1 %C, label %T, label %F, !prof !5
107 define i32 @sgt(i32 %X, i32 %Y) {
109 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
110 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !6
112 ; CHECK-NEXT: ret i32 12
114 ; CHECK-NEXT: ret i32 123
116 %C = icmp sgt i32 %X, %Y
117 br i1 %C, label %T, label %F, !prof !6
124 define i32 @sge(i32 %X, i32 %Y) {
126 ; CHECK-NEXT: [[C:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]]
127 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !7
129 ; CHECK-NEXT: ret i32 12
131 ; CHECK-NEXT: ret i32 123
133 %C = icmp sge i32 %X, %Y
134 br i1 %C, label %T, label %F, !prof !7
141 define i32 @slt(i32 %X, i32 %Y) {
143 ; CHECK-NEXT: [[C:%.*]] = icmp slt i32 [[X:%.*]], [[Y:%.*]]
144 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !8
146 ; CHECK-NEXT: ret i32 12
148 ; CHECK-NEXT: ret i32 123
150 %C = icmp slt i32 %X, %Y
151 br i1 %C, label %T, label %F, !prof !8
158 define i32 @sle(i32 %X, i32 %Y) {
160 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
161 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !9
163 ; CHECK-NEXT: ret i32 12
165 ; CHECK-NEXT: ret i32 123
167 %C = icmp sle i32 %X, %Y
168 br i1 %C, label %T, label %F, !prof !9
175 define i32 @f_false(float %X, float %Y) {
176 ; CHECK-LABEL: @f_false(
177 ; CHECK-NEXT: br i1 false, label [[T:%.*]], label [[F:%.*]], !prof !10
179 ; CHECK-NEXT: ret i32 12
181 ; CHECK-NEXT: ret i32 123
183 %C = fcmp false float %X, %Y
184 br i1 %C, label %T, label %F, !prof !10
191 define i32 @f_oeq(float %X, float %Y) {
192 ; CHECK-LABEL: @f_oeq(
193 ; CHECK-NEXT: [[C:%.*]] = fcmp oeq float [[X:%.*]], [[Y:%.*]]
194 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !11
196 ; CHECK-NEXT: ret i32 12
198 ; CHECK-NEXT: ret i32 123
200 %C = fcmp oeq float %X, %Y
201 br i1 %C, label %T, label %F, !prof !11
208 define i32 @f_ogt(float %X, float %Y) {
209 ; CHECK-LABEL: @f_ogt(
210 ; CHECK-NEXT: [[C:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
211 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !12
213 ; CHECK-NEXT: ret i32 12
215 ; CHECK-NEXT: ret i32 123
217 %C = fcmp ogt float %X, %Y
218 br i1 %C, label %T, label %F, !prof !12
225 define i32 @f_oge(float %X, float %Y) {
226 ; CHECK-LABEL: @f_oge(
227 ; CHECK-NEXT: [[C:%.*]] = fcmp ult float [[X:%.*]], [[Y:%.*]]
228 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !13
230 ; CHECK-NEXT: ret i32 12
232 ; CHECK-NEXT: ret i32 123
234 %C = fcmp oge float %X, %Y
235 br i1 %C, label %T, label %F, !prof !13
242 define i32 @f_olt(float %X, float %Y) {
243 ; CHECK-LABEL: @f_olt(
244 ; CHECK-NEXT: [[C:%.*]] = fcmp olt float [[X:%.*]], [[Y:%.*]]
245 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !14
247 ; CHECK-NEXT: ret i32 12
249 ; CHECK-NEXT: ret i32 123
251 %C = fcmp olt float %X, %Y
252 br i1 %C, label %T, label %F, !prof !14
259 define i32 @f_ole(float %X, float %Y) {
260 ; CHECK-LABEL: @f_ole(
261 ; CHECK-NEXT: [[C:%.*]] = fcmp ugt float [[X:%.*]], [[Y:%.*]]
262 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !15
264 ; CHECK-NEXT: ret i32 12
266 ; CHECK-NEXT: ret i32 123
268 %C = fcmp ole float %X, %Y
269 br i1 %C, label %T, label %F, !prof !15
276 define i32 @f_one(float %X, float %Y) {
277 ; CHECK-LABEL: @f_one(
278 ; CHECK-NEXT: [[C:%.*]] = fcmp ueq float [[X:%.*]], [[Y:%.*]]
279 ; CHECK-NEXT: br i1 [[C]], label [[F:%.*]], label [[T:%.*]], !prof !16
281 ; CHECK-NEXT: ret i32 12
283 ; CHECK-NEXT: ret i32 123
285 %C = fcmp one float %X, %Y
286 br i1 %C, label %T, label %F, !prof !16
293 define i32 @f_ord(float %X, float %Y) {
294 ; CHECK-LABEL: @f_ord(
295 ; CHECK-NEXT: [[C:%.*]] = fcmp ord float [[X:%.*]], [[Y:%.*]]
296 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !17
298 ; CHECK-NEXT: ret i32 12
300 ; CHECK-NEXT: ret i32 123
302 %C = fcmp ord float %X, %Y
303 br i1 %C, label %T, label %F, !prof !17
310 define i32 @f_uno(float %X, float %Y) {
311 ; CHECK-LABEL: @f_uno(
312 ; CHECK-NEXT: [[C:%.*]] = fcmp uno float [[X:%.*]], [[Y:%.*]]
313 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !18
315 ; CHECK-NEXT: ret i32 12
317 ; CHECK-NEXT: ret i32 123
319 %C = fcmp uno float %X, %Y
320 br i1 %C, label %T, label %F, !prof !18
327 define i32 @f_ueq(float %X, float %Y) {
328 ; CHECK-LABEL: @f_ueq(
329 ; CHECK-NEXT: [[C:%.*]] = fcmp ueq float [[X:%.*]], [[Y:%.*]]
330 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !19
332 ; CHECK-NEXT: ret i32 12
334 ; CHECK-NEXT: ret i32 123
336 %C = fcmp ueq float %X, %Y
337 br i1 %C, label %T, label %F, !prof !19
344 define i32 @f_ugt(float %X, float %Y) {
345 ; CHECK-LABEL: @f_ugt(
346 ; CHECK-NEXT: [[C:%.*]] = fcmp ugt float [[X:%.*]], [[Y:%.*]]
347 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !20
349 ; CHECK-NEXT: ret i32 12
351 ; CHECK-NEXT: ret i32 123
353 %C = fcmp ugt float %X, %Y
354 br i1 %C, label %T, label %F, !prof !20
361 define i32 @f_uge(float %X, float %Y) {
362 ; CHECK-LABEL: @f_uge(
363 ; CHECK-NEXT: [[C:%.*]] = fcmp uge float [[X:%.*]], [[Y:%.*]]
364 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !21
366 ; CHECK-NEXT: ret i32 12
368 ; CHECK-NEXT: ret i32 123
370 %C = fcmp uge float %X, %Y
371 br i1 %C, label %T, label %F, !prof !21
378 define i32 @f_ult(float %X, float %Y) {
379 ; CHECK-LABEL: @f_ult(
380 ; CHECK-NEXT: [[C:%.*]] = fcmp ult float [[X:%.*]], [[Y:%.*]]
381 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !22
383 ; CHECK-NEXT: ret i32 12
385 ; CHECK-NEXT: ret i32 123
387 %C = fcmp ult float %X, %Y
388 br i1 %C, label %T, label %F, !prof !22
395 define i32 @f_ule(float %X, float %Y) {
396 ; CHECK-LABEL: @f_ule(
397 ; CHECK-NEXT: [[C:%.*]] = fcmp ule float [[X:%.*]], [[Y:%.*]]
398 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !23
400 ; CHECK-NEXT: ret i32 12
402 ; CHECK-NEXT: ret i32 123
404 %C = fcmp ule float %X, %Y
405 br i1 %C, label %T, label %F, !prof !23
412 define i32 @f_une(float %X, float %Y) {
413 ; CHECK-LABEL: @f_une(
414 ; CHECK-NEXT: [[C:%.*]] = fcmp une float [[X:%.*]], [[Y:%.*]]
415 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]], !prof !24
417 ; CHECK-NEXT: ret i32 12
419 ; CHECK-NEXT: ret i32 123
421 %C = fcmp une float %X, %Y
422 br i1 %C, label %T, label %F, !prof !24
429 define i32 @f_true(float %X, float %Y) {
430 ; CHECK-LABEL: @f_true(
431 ; CHECK-NEXT: br i1 true, label [[T:%.*]], label [[F:%.*]], !prof !25
433 ; CHECK-NEXT: ret i32 12
435 ; CHECK-NEXT: ret i32 123
437 %C = fcmp true float %X, %Y
438 br i1 %C, label %T, label %F, !prof !25
446 !0 = !{!"branch_weights", i32 0, i32 99}
447 !1 = !{!"branch_weights", i32 1, i32 99}
448 !2 = !{!"branch_weights", i32 2, i32 99}
449 !3 = !{!"branch_weights", i32 3, i32 99}
450 !4 = !{!"branch_weights", i32 4, i32 99}
451 !5 = !{!"branch_weights", i32 5, i32 99}
452 !6 = !{!"branch_weights", i32 6, i32 99}
453 !7 = !{!"branch_weights", i32 7, i32 99}
454 !8 = !{!"branch_weights", i32 8, i32 99}
455 !9 = !{!"branch_weights", i32 9, i32 99}
456 !10 = !{!"branch_weights", i32 10, i32 99}
457 !11 = !{!"branch_weights", i32 11, i32 99}
458 !12 = !{!"branch_weights", i32 12, i32 99}
459 !13 = !{!"branch_weights", i32 13, i32 99}
460 !14 = !{!"branch_weights", i32 14, i32 99}
461 !15 = !{!"branch_weights", i32 15, i32 99}
462 !16 = !{!"branch_weights", i32 16, i32 99}
463 !17 = !{!"branch_weights", i32 17, i32 99}
464 !18 = !{!"branch_weights", i32 18, i32 99}
465 !19 = !{!"branch_weights", i32 19, i32 99}
466 !20 = !{!"branch_weights", i32 20, i32 99}
467 !21 = !{!"branch_weights", i32 21, i32 99}
468 !22 = !{!"branch_weights", i32 22, i32 99}
469 !23 = !{!"branch_weights", i32 23, i32 99}
470 !24 = !{!"branch_weights", i32 24, i32 99}
471 !25 = !{!"branch_weights", i32 25, i32 99}
473 ; Ensure that the branch metadata is reversed to match the reversals above.
474 ; CHECK: !0 = {{.*}} i32 0, i32 99}
475 ; CHECK: !1 = {{.*}} i32 99, i32 1}
476 ; CHECK: !2 = {{.*}} i32 2, i32 99}
477 ; CHECK: !3 = {{.*}} i32 99, i32 3}
478 ; CHECK: !4 = {{.*}} i32 4, i32 99}
479 ; CHECK: !5 = {{.*}} i32 99, i32 5}
480 ; CHECK: !6 = {{.*}} i32 6, i32 99}
481 ; CHECK: !7 = {{.*}} i32 99, i32 7}
482 ; CHECK: !8 = {{.*}} i32 8, i32 99}
483 ; CHECK: !9 = {{.*}} i32 99, i32 9}
484 ; CHECK: !10 = {{.*}} i32 10, i32 99}
485 ; CHECK: !11 = {{.*}} i32 11, i32 99}
486 ; CHECK: !12 = {{.*}} i32 12, i32 99}
487 ; CHECK: !13 = {{.*}} i32 99, i32 13}
488 ; CHECK: !14 = {{.*}} i32 14, i32 99}
489 ; CHECK: !15 = {{.*}} i32 99, i32 15}
490 ; CHECK: !16 = {{.*}} i32 99, i32 16}
491 ; CHECK: !17 = {{.*}} i32 17, i32 99}
492 ; CHECK: !18 = {{.*}} i32 18, i32 99}
493 ; CHECK: !19 = {{.*}} i32 19, i32 99}
494 ; CHECK: !20 = {{.*}} i32 20, i32 99}
495 ; CHECK: !21 = {{.*}} i32 21, i32 99}
496 ; CHECK: !22 = {{.*}} i32 22, i32 99}
497 ; CHECK: !23 = {{.*}} i32 23, i32 99}
498 ; CHECK: !24 = {{.*}} i32 24, i32 99}
499 ; CHECK: !25 = {{.*}} i32 25, i32 99}