1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=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: call void @use(i1 true)
13 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[X]], 10
14 ; CHECK-NEXT: call void @use(i1 [[C_2]])
15 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i32 [[Y]], [[X]]
16 ; CHECK-NEXT: call void @use(i1 [[C_3]])
17 ; CHECK-NEXT: [[C_4:%.*]] = icmp sge i32 10, [[X]]
18 ; CHECK-NEXT: call void @use(i1 [[C_4]])
19 ; CHECK-NEXT: ret void
21 ; CHECK-NEXT: call void @use(i1 true)
22 ; CHECK-NEXT: call void @use(i1 false)
23 ; CHECK-NEXT: [[C_5:%.*]] = icmp sge i32 [[X]], 10
24 ; CHECK-NEXT: call void @use(i1 [[C_5]])
25 ; CHECK-NEXT: [[C_6:%.*]] = icmp sge i32 10, [[X]]
26 ; CHECK-NEXT: call void @use(i1 [[C_6]])
27 ; CHECK-NEXT: ret void
30 %c.1 = icmp sge i32 %x, %y
31 br i1 %c.1, label %bb1, label %bb2
34 %t.1 = icmp sge i32 %x, %y
35 call void @use(i1 %t.1)
36 %c.2 = icmp sge i32 %x, 10
37 call void @use(i1 %c.2)
38 %c.3 = icmp sge i32 %y, %x
39 call void @use(i1 %c.3)
40 %c.4 = icmp sge i32 10, %x
41 call void @use(i1 %c.4)
45 %t.2 = icmp sge i32 %y, %x
46 call void @use(i1 %t.2)
47 %f.1 = icmp sge i32 %x, %y
48 call void @use(i1 %f.1)
49 %c.5 = icmp sge i32 %x, 10
50 call void @use(i1 %c.5)
51 %c.6 = icmp sge i32 10, %x
52 call void @use(i1 %c.6)
56 define void @test_1_constant_constraint(i32 %x) {
57 ; CHECK-LABEL: @test_1_constant_constraint(
59 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], 10
60 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[BB2:%.*]]
62 ; CHECK-NEXT: call void @use(i1 true)
63 ; CHECK-NEXT: call void @use(i1 true)
64 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[X]], 11
65 ; CHECK-NEXT: call void @use(i1 [[C_2]])
66 ; CHECK-NEXT: [[C_4:%.*]] = icmp sge i32 10, [[X]]
67 ; CHECK-NEXT: call void @use(i1 [[C_4]])
68 ; CHECK-NEXT: ret void
70 ; CHECK-NEXT: call void @use(i1 true)
71 ; CHECK-NEXT: call void @use(i1 false)
72 ; CHECK-NEXT: call void @use(i1 false)
73 ; CHECK-NEXT: [[C_5:%.*]] = icmp sge i32 [[X]], 9
74 ; CHECK-NEXT: call void @use(i1 [[C_5]])
75 ; CHECK-NEXT: [[C_6:%.*]] = icmp sge i32 1, [[X]]
76 ; CHECK-NEXT: call void @use(i1 [[C_6]])
77 ; CHECK-NEXT: ret void
80 %c.1 = icmp sge i32 %x, 10
81 br i1 %c.1, label %bb1, label %bb2
84 %t.1 = icmp sge i32 %x, 10
85 call void @use(i1 %t.1)
86 %t.2 = icmp sge i32 %x, 9
87 call void @use(i1 %t.2)
88 %c.2 = icmp sge i32 %x, 11
89 call void @use(i1 %c.2)
90 %c.4 = icmp sge i32 10, %x
91 call void @use(i1 %c.4)
95 %t.3 = icmp sge i32 11, %x
96 call void @use(i1 %t.3)
97 %f.1 = icmp sge i32 %x, 10
98 call void @use(i1 %f.1)
101 %f.1.1 = icmp sge i32 %x, 10
102 call void @use(i1 %f.1.1)
103 %c.5 = icmp sge i32 %x, 9
104 call void @use(i1 %c.5)
105 %c.6 = icmp sge i32 1, %x
106 call void @use(i1 %c.6)
110 define i32 @test1(i32 %x, i32 %y, i32 %z) {
111 ; CHECK-LABEL: @test1(
113 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
114 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
116 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y]], [[Z:%.*]]
117 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
119 ; CHECK-NEXT: br i1 true, label [[BB3:%.*]], label [[EXIT]]
121 ; CHECK-NEXT: ret i32 10
123 ; CHECK-NEXT: ret i32 20
126 %c.1 = icmp sge i32 %x, %y
127 br i1 %c.1, label %bb1, label %exit
130 %c.2 = icmp sge i32 %y, %z
131 br i1 %c.2, label %bb2, label %exit
134 %c.3 = icmp sge i32 %x, %z
135 br i1 %c.3, label %bb3, label %exit
144 define i32 @test2(i32 %x, i32 %y, i32 %z, i32 %a) {
145 ; CHECK-LABEL: @test2(
147 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
148 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
150 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y]], [[Z:%.*]]
151 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
153 ; CHECK-NEXT: [[C_3:%.*]] = icmp sge i32 [[X]], [[A:%.*]]
154 ; CHECK-NEXT: br i1 [[C_3]], label [[BB3:%.*]], label [[EXIT]]
156 ; CHECK-NEXT: ret i32 10
158 ; CHECK-NEXT: ret i32 20
161 %c.1 = icmp sge i32 %x, %y
162 br i1 %c.1, label %bb1, label %exit
165 %c.2 = icmp sge i32 %y, %z
166 br i1 %c.2, label %bb2, label %exit
169 %c.3 = icmp sge i32 %x, %a
170 br i1 %c.3, label %bb3, label %exit
180 define i32 @test3(i32 %x, i32 %y) {
181 ; CHECK-LABEL: @test3(
183 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], 10
184 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
186 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y:%.*]], 20
187 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
189 ; CHECK-NEXT: ret i32 10
191 ; CHECK-NEXT: ret i32 20
194 %c.1 = icmp sge i32 %x, 10
195 br i1 %c.1, label %bb1, label %exit
198 %c.2 = icmp sge i32 %y, 20
199 br i1 %c.2, label %bb2, label %exit
208 define i32 @test4(i32 %x, i32 %y, i32 %z) {
209 ; CHECK-LABEL: @test4(
211 ; CHECK-NEXT: [[C_1:%.*]] = icmp sge i32 [[X:%.*]], [[Y:%.*]]
212 ; CHECK-NEXT: br i1 [[C_1]], label [[BB1:%.*]], label [[EXIT:%.*]]
214 ; CHECK-NEXT: [[C_2:%.*]] = icmp sge i32 [[Y]], [[Z:%.*]]
215 ; CHECK-NEXT: br i1 [[C_2]], label [[BB2:%.*]], label [[EXIT]]
217 ; CHECK-NEXT: call void @use(i1 true)
218 ; CHECK-NEXT: [[U_1:%.*]] = icmp eq i32 [[X]], [[Z]]
219 ; CHECK-NEXT: call void @use(i1 [[U_1]])
220 ; CHECK-NEXT: ret i32 10
222 ; CHECK-NEXT: ret i32 20
225 %c.1 = icmp sge i32 %x, %y
226 br i1 %c.1, label %bb1, label %exit
229 %c.2 = icmp sge i32 %y, %z
230 br i1 %c.2, label %bb2, label %exit
233 %t.1 = icmp sge i32 %x, %z
234 call void @use(i1 %t.1)
235 %u.1 = icmp eq i32 %x, %z
236 call void @use(i1 %u.1)
244 define i1 @sge_sgt(i32 %x, i32 %y, i32 %z) {
245 ; CHECK-LABEL: @sge_sgt(
247 ; CHECK-NEXT: [[C_1:%.*]] = icmp sgt i32 [[X:%.*]], -1
248 ; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[ELSE:%.*]]
250 ; CHECK-NEXT: ret i1 true
252 ; CHECK-NEXT: ret i1 false
255 %c.1 = icmp sgt i32 %x, -1
256 br i1 %c.1, label %then, label %else
259 %t.1 = icmp sge i32 %x, 0
263 %f.1 = icmp sge i32 %x, 0