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 sge i32 [[X:%.*]], [[Y:%.*]]
10 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
12 ; CHECK-NEXT: [[T_1:%.*]] = icmp sge i32 [[X]], [[Y]]
13 ; CHECK-NEXT: call void @use(i1 [[T_1]])
14 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[X]], 10
15 ; CHECK-NEXT: call void @use(i1 [[C_2]])
16 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i32 [[Y]], [[X]]
17 ; CHECK-NEXT: call void @use(i1 [[C_3]])
18 ; CHECK-NEXT: [[C_4:%.*]] = icmp sge i32 10, [[X]]
19 ; CHECK-NEXT: call void @use(i1 [[C_4]])
20 ; CHECK-NEXT: ret void
22 ; CHECK-NEXT: [[T_2:%.*]] = icmp sge i32 [[Y]], [[X]]
23 ; CHECK-NEXT: call void @use(i1 [[T_2]])
24 ; CHECK-NEXT: [[F_1:%.*]] = icmp sge i32 [[X]], [[Y]]
25 ; CHECK-NEXT: call void @use(i1 [[F_1]])
26 ; CHECK-NEXT: [[C_5:%.*]] = icmp sge i32 [[X]], 10
27 ; CHECK-NEXT: call void @use(i1 [[C_5]])
28 ; CHECK-NEXT: [[C_6:%.*]] = icmp sge i32 10, [[X]]
29 ; CHECK-NEXT: call void @use(i1 [[C_6]])
30 ; CHECK-NEXT: ret void
33 %c.1 = icmp sge i32 %x, %y
34 br i1 %c.1, label %bb1, label %bb2
37 %t.1 = icmp sge i32 %x, %y
38 call void @use(i1 %t.1)
39 %c.2 = icmp sge i32 %x, 10
40 call void @use(i1 %c.2)
41 %c.3 = icmp sge i32 %y, %x
42 call void @use(i1 %c.3)
43 %c.4 = icmp sge i32 10, %x
44 call void @use(i1 %c.4)
48 %t.2 = icmp sge i32 %y, %x
49 call void @use(i1 %t.2)
50 %f.1 = icmp sge i32 %x, %y
51 call void @use(i1 %f.1)
52 %c.5 = icmp sge i32 %x, 10
53 call void @use(i1 %c.5)
54 %c.6 = icmp sge 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 sge i32 [[X:%.*]], 10
63 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
65 ; CHECK-NEXT: [[T_1:%.*]] = icmp sge i32 [[X]], 10
66 ; CHECK-NEXT: call void @use(i1 [[T_1]])
67 ; CHECK-NEXT: [[T_2:%.*]] = icmp sge i32 [[X]], 9
68 ; CHECK-NEXT: call void @use(i1 [[T_2]])
69 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[X]], 11
70 ; CHECK-NEXT: call void @use(i1 [[C_2]])
71 ; CHECK-NEXT: [[C_4:%.*]] = icmp sge i32 10, [[X]]
72 ; CHECK-NEXT: call void @use(i1 [[C_4]])
73 ; CHECK-NEXT: ret void
75 ; CHECK-NEXT: [[T_3:%.*]] = icmp sge i32 11, [[X]]
76 ; CHECK-NEXT: call void @use(i1 [[T_3]])
77 ; CHECK-NEXT: [[F_1:%.*]] = icmp sge i32 [[X]], 10
78 ; CHECK-NEXT: call void @use(i1 [[F_1]])
79 ; CHECK-NEXT: [[F_1_1:%.*]] = icmp sge i32 [[X]], 10
80 ; CHECK-NEXT: call void @use(i1 [[F_1_1]])
81 ; CHECK-NEXT: [[C_5:%.*]] = icmp sge i32 [[X]], 9
82 ; CHECK-NEXT: call void @use(i1 [[C_5]])
83 ; CHECK-NEXT: [[C_6:%.*]] = icmp sge i32 1, [[X]]
84 ; CHECK-NEXT: call void @use(i1 [[C_6]])
85 ; CHECK-NEXT: ret void
88 %c.1 = icmp sge i32 %x, 10
89 br i1 %c.1, label %bb1, label %bb2
92 %t.1 = icmp sge i32 %x, 10
93 call void @use(i1 %t.1)
94 %t.2 = icmp sge i32 %x, 9
95 call void @use(i1 %t.2)
96 %c.2 = icmp sge i32 %x, 11
97 call void @use(i1 %c.2)
98 %c.4 = icmp sge i32 10, %x
99 call void @use(i1 %c.4)
103 %t.3 = icmp sge i32 11, %x
104 call void @use(i1 %t.3)
105 %f.1 = icmp sge i32 %x, 10
106 call void @use(i1 %f.1)
109 %f.1.1 = icmp sge i32 %x, 10
110 call void @use(i1 %f.1.1)
111 %c.5 = icmp sge i32 %x, 9
112 call void @use(i1 %c.5)
113 %c.6 = icmp sge i32 1, %x
114 call void @use(i1 %c.6)
118 define i32 @test1(i32 %x, i32 %y, i32 %z) {
119 ; CHECK-LABEL: @test1(
121 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
122 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
124 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y]], [[Z:%.*]]
125 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
127 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i32 [[X]], [[Z]]
128 ; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
130 ; CHECK-NEXT: ret i32 10
132 ; CHECK-NEXT: ret i32 20
135 %c.1 = icmp sge i32 %x, %y
136 br i1 %c.1, label %bb1, label %exit
139 %c.2 = icmp sge i32 %y, %z
140 br i1 %c.2, label %bb2, label %exit
143 %c.3 = icmp sge i32 %x, %z
144 br i1 %c.3, label %bb3, label %exit
153 define i32 @test2(i32 %x, i32 %y, i32 %z, i32 %a) {
154 ; CHECK-LABEL: @test2(
156 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
157 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
159 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y]], [[Z:%.*]]
160 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
162 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i32 [[X]], [[A:%.*]]
163 ; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
165 ; CHECK-NEXT: ret i32 10
167 ; CHECK-NEXT: ret i32 20
170 %c.1 = icmp sge i32 %x, %y
171 br i1 %c.1, label %bb1, label %exit
174 %c.2 = icmp sge i32 %y, %z
175 br i1 %c.2, label %bb2, label %exit
178 %c.3 = icmp sge i32 %x, %a
179 br i1 %c.3, label %bb3, label %exit
189 define i32 @test3(i32 %x, i32 %y) {
190 ; CHECK-LABEL: @test3(
192 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], 10
193 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
195 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y:%.*]], 20
196 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
198 ; CHECK-NEXT: ret i32 10
200 ; CHECK-NEXT: ret i32 20
203 %c.1 = icmp sge i32 %x, 10
204 br i1 %c.1, label %bb1, label %exit
207 %c.2 = icmp sge i32 %y, 20
208 br i1 %c.2, label %bb2, label %exit
217 define i32 @test4(i32 %x, i32 %y, i32 %z) {
218 ; CHECK-LABEL: @test4(
220 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
221 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
223 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y]], [[Z:%.*]]
224 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
226 ; CHECK-NEXT: [[T_1:%.*]] = icmp sge i32 [[X]], [[Z]]
227 ; CHECK-NEXT: call void @use(i1 [[T_1]])
228 ; CHECK-NEXT: [[U_1:%.*]] = icmp eq i32 [[X]], [[Z]]
229 ; CHECK-NEXT: call void @use(i1 [[U_1]])
230 ; CHECK-NEXT: ret i32 10
232 ; CHECK-NEXT: ret i32 20
235 %c.1 = icmp sge i32 %x, %y
236 br i1 %c.1, label %bb1, label %exit
239 %c.2 = icmp sge i32 %y, %z
240 br i1 %c.2, label %bb2, label %exit
243 %t.1 = icmp sge i32 %x, %z
244 call void @use(i1 %t.1)
245 %u.1 = icmp eq i32 %x, %z
246 call void @use(i1 %u.1)