1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -constraint-elimination -S %s | FileCheck %s
6 define void @test_1_variable_constraint(i32 %x, i32 %y, i32 %z) {
7 ; CHECK-LABEL: @test_1_variable_constraint(
9 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
10 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
12 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], [[Y]]
13 ; CHECK-NEXT: call void @use(i1 true)
14 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 10
15 ; CHECK-NEXT: call void @use(i1 [[C_2]])
16 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[Y]], [[X]]
17 ; CHECK-NEXT: call void @use(i1 [[C_3]])
18 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i32 10, [[X]]
19 ; CHECK-NEXT: call void @use(i1 [[C_4]])
20 ; CHECK-NEXT: ret void
22 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i32 [[Y]], [[X]]
23 ; CHECK-NEXT: call void @use(i1 true)
24 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i32 [[X]], [[Y]]
25 ; CHECK-NEXT: call void @use(i1 false)
26 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], 10
27 ; CHECK-NEXT: call void @use(i1 [[C_5]])
28 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i32 10, [[X]]
29 ; CHECK-NEXT: call void @use(i1 [[C_6]])
30 ; CHECK-NEXT: ret void
33 %c.1 = icmp ule i32 %x, %y
34 br i1 %c.1, label %bb1, label %bb2
37 %t.1 = icmp ule i32 %x, %y
38 call void @use(i1 %t.1)
39 %c.2 = icmp ule i32 %x, 10
40 call void @use(i1 %c.2)
41 %c.3 = icmp ule i32 %y, %x
42 call void @use(i1 %c.3)
43 %c.4 = icmp ule i32 10, %x
44 call void @use(i1 %c.4)
48 %t.2 = icmp ule i32 %y, %x
49 call void @use(i1 %t.2)
50 %f.1 = icmp ule i32 %x, %y
51 call void @use(i1 %f.1)
52 %c.5 = icmp ule i32 %x, 10
53 call void @use(i1 %c.5)
54 %c.6 = icmp ule i32 10, %x
55 call void @use(i1 %c.6)
59 define void @test_1_constant_constraint(i32 %x) {
60 ; CHECK-LABEL: @test_1_constant_constraint(
62 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
63 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
65 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], 10
66 ; CHECK-NEXT: call void @use(i1 true)
67 ; CHECK-NEXT: [[T_2:%.*]] = icmp ule i32 [[X]], 11
68 ; CHECK-NEXT: call void @use(i1 true)
69 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[X]], 9
70 ; CHECK-NEXT: call void @use(i1 [[C_2]])
71 ; CHECK-NEXT: [[C_4:%.*]] = icmp ule i32 10, [[X]]
72 ; CHECK-NEXT: call void @use(i1 [[C_4]])
73 ; CHECK-NEXT: ret void
75 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i32 10, [[X]]
76 ; CHECK-NEXT: call void @use(i1 true)
77 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i32 [[X]], 9
78 ; CHECK-NEXT: call void @use(i1 false)
79 ; CHECK-NEXT: [[F_1_1:%.*]] = icmp ule i32 [[X]], 10
80 ; CHECK-NEXT: call void @use(i1 false)
81 ; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], 11
82 ; CHECK-NEXT: call void @use(i1 [[C_5]])
83 ; CHECK-NEXT: [[C_6:%.*]] = icmp ule i32 12, [[X]]
84 ; CHECK-NEXT: call void @use(i1 [[C_6]])
85 ; CHECK-NEXT: ret void
88 %c.1 = icmp ule i32 %x, 10
89 br i1 %c.1, label %bb1, label %bb2
92 %t.1 = icmp ule i32 %x, 10
93 call void @use(i1 %t.1)
94 %t.2 = icmp ule i32 %x, 11
95 call void @use(i1 %t.2)
96 %c.2 = icmp ule i32 %x, 9
97 call void @use(i1 %c.2)
98 %c.4 = icmp ule i32 10, %x
99 call void @use(i1 %c.4)
103 %t.3 = icmp ule i32 10, %x
104 call void @use(i1 %t.3)
105 %f.1 = icmp ule i32 %x, 9
106 call void @use(i1 %f.1)
109 %f.1.1 = icmp ule i32 %x, 10
110 call void @use(i1 %f.1.1)
111 %c.5 = icmp ule i32 %x, 11
112 call void @use(i1 %c.5)
113 %c.6 = icmp ule i32 12, %x
114 call void @use(i1 %c.6)
119 define i32 @test1(i32 %x, i32 %y, i32 %z) {
120 ; CHECK-LABEL: @test1(
122 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
123 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
125 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
126 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
128 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], [[Z]]
129 ; CHECK-NEXT: br i1 true, label [[BB3:%.*]], label [[EXIT]]
131 ; CHECK-NEXT: ret i32 10
133 ; CHECK-NEXT: ret i32 20
136 %c.1 = icmp ule i32 %x, %y
137 br i1 %c.1, label %bb1, label %exit
140 %c.2 = icmp ule i32 %y, %z
141 br i1 %c.2, label %bb2, label %exit
144 %c.3 = icmp ule i32 %x, %z
145 br i1 %c.3, label %bb3, label %exit
155 define i32 @test2(i32 %x, i32 %y, i32 %z, i32 %a) {
156 ; CHECK-LABEL: @test2(
158 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
159 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
161 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
162 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
164 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i32 [[X]], [[A:%.*]]
165 ; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
167 ; CHECK-NEXT: ret i32 10
169 ; CHECK-NEXT: ret i32 20
172 %c.1 = icmp ule i32 %x, %y
173 br i1 %c.1, label %bb1, label %exit
176 %c.2 = icmp ule i32 %y, %z
177 br i1 %c.2, label %bb2, label %exit
180 %c.3 = icmp ule i32 %x, %a
181 br i1 %c.3, label %bb3, label %exit
191 define i32 @test3(i32 %x, i32 %y) {
192 ; CHECK-LABEL: @test3(
194 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], 10
195 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
197 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y:%.*]], 20
198 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
200 ; CHECK-NEXT: ret i32 10
202 ; CHECK-NEXT: ret i32 20
205 %c.1 = icmp ule i32 %x, 10
206 br i1 %c.1, label %bb1, label %exit
209 %c.2 = icmp ule i32 %y, 20
210 br i1 %c.2, label %bb2, label %exit
219 define i32 @test4(i32 %x, i32 %y, i32 %z) {
220 ; CHECK-LABEL: @test4(
222 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
223 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
225 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i32 [[Y]], [[Z:%.*]]
226 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
228 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i32 [[X]], [[Z]]
229 ; CHECK-NEXT: call void @use(i1 true)
230 ; CHECK-NEXT: [[U_1:%.*]] = icmp eq i32 [[X]], [[Z]]
231 ; CHECK-NEXT: call void @use(i1 [[U_1]])
232 ; CHECK-NEXT: ret i32 10
234 ; CHECK-NEXT: ret i32 20
237 %c.1 = icmp ule i32 %x, %y
238 br i1 %c.1, label %bb1, label %exit
241 %c.2 = icmp ule i32 %y, %z
242 br i1 %c.2, label %bb2, label %exit
245 %t.1 = icmp ule i32 %x, %z
246 call void @use(i1 %t.1)
247 %u.1 = icmp eq i32 %x, %z
248 call void @use(i1 %u.1)