1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -early-cse -S < %s | FileCheck %s
3 ; RUN: opt -basicaa -early-cse-memssa -S < %s | FileCheck %s
5 define i32 @test_01(i32 %a, i32 %b) {
6 ; CHECK-LABEL: @test_01(
8 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
9 ; CHECK-NEXT: br i1 [[COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
11 ; CHECK-NEXT: ret i32 [[A]]
13 ; CHECK-NEXT: ret i32 [[B]]
16 %cond = icmp slt i32 %a, %b
17 br i1 %cond, label %if.true, label %if.false
20 %cond2 = icmp slt i32 %a, %b
21 %x = select i1 %cond2, i32 %a, i32 %b
25 %cond3 = icmp slt i32 %a, %b
26 %y = select i1 %cond3, i32 %a, i32 %b
30 define i32 @test_02(i32 %a, i32 %b, i1 %c) {
31 ; CHECK-LABEL: @test_02(
33 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
34 ; CHECK-NEXT: [[AND_COND:%.*]] = and i1 [[COND]], [[C:%.*]]
35 ; CHECK-NEXT: br i1 [[AND_COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
37 ; CHECK-NEXT: ret i32 [[A]]
39 ; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
40 ; CHECK-NEXT: ret i32 [[Y]]
43 %cond = icmp slt i32 %a, %b
44 %and.cond = and i1 %cond, %c
45 br i1 %and.cond, label %if.true, label %if.false
48 %cond2 = icmp slt i32 %a, %b
49 %x = select i1 %cond2, i32 %a, i32 %b
53 %cond3 = icmp slt i32 %a, %b
54 %y = select i1 %cond3, i32 %a, i32 %b
58 define i32 @test_03(i32 %a, i32 %b, i1 %c) {
59 ; CHECK-LABEL: @test_03(
61 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
62 ; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[COND]], [[C:%.*]]
63 ; CHECK-NEXT: br i1 [[OR_COND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
65 ; CHECK-NEXT: [[X:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
66 ; CHECK-NEXT: ret i32 [[X]]
68 ; CHECK-NEXT: ret i32 [[B]]
71 %cond = icmp slt i32 %a, %b
72 %or.cond = or i1 %cond, %c
73 br i1 %or.cond, label %if.true, label %if.false
76 %cond2 = icmp slt i32 %a, %b
77 %x = select i1 %cond2, i32 %a, i32 %b
81 %cond3 = icmp slt i32 %a, %b
82 %y = select i1 %cond3, i32 %a, i32 %b
86 define i32 @test_04(i32 %a, i32 %b, i1 %c1, i1 %c2) {
87 ; CHECK-LABEL: @test_04(
89 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
90 ; CHECK-NEXT: [[AND_COND1:%.*]] = and i1 [[COND]], [[C1:%.*]]
91 ; CHECK-NEXT: [[AND_COND2:%.*]] = and i1 [[AND_COND1]], [[C2:%.*]]
92 ; CHECK-NEXT: br i1 [[AND_COND2]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
94 ; CHECK-NEXT: ret i32 [[A]]
96 ; CHECK-NEXT: [[Y:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
97 ; CHECK-NEXT: ret i32 [[Y]]
100 %cond = icmp slt i32 %a, %b
101 %and.cond1 = and i1 %cond, %c1
102 %and.cond2 = and i1 %and.cond1, %c2
103 br i1 %and.cond2, label %if.true, label %if.false
106 %cond2 = icmp slt i32 %a, %b
107 %x = select i1 %cond2, i32 %a, i32 %b
111 %cond3 = icmp slt i32 %a, %b
112 %y = select i1 %cond3, i32 %a, i32 %b
116 define i32 @test_05(i32 %a, i32 %b, i1 %c1, i1 %c2) {
117 ; CHECK-LABEL: @test_05(
119 ; CHECK-NEXT: [[COND:%.*]] = icmp slt i32 [[A:%.*]], [[B:%.*]]
120 ; CHECK-NEXT: [[OR_COND1:%.*]] = or i1 [[COND]], [[C1:%.*]]
121 ; CHECK-NEXT: [[OR_COND2:%.*]] = or i1 [[OR_COND1]], [[C2:%.*]]
122 ; CHECK-NEXT: br i1 [[OR_COND2]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
124 ; CHECK-NEXT: [[X:%.*]] = select i1 [[COND]], i32 [[A]], i32 [[B]]
125 ; CHECK-NEXT: ret i32 [[X]]
127 ; CHECK-NEXT: ret i32 [[B]]
130 %cond = icmp slt i32 %a, %b
131 %or.cond1 = or i1 %cond, %c1
132 %or.cond2 = or i1 %or.cond1, %c2
133 br i1 %or.cond2, label %if.true, label %if.false
136 %cond2 = icmp slt i32 %a, %b
137 %x = select i1 %cond2, i32 %a, i32 %b
141 %cond3 = icmp slt i32 %a, %b
142 %y = select i1 %cond3, i32 %a, i32 %b