1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
4 ; s >= t, s != t, s <= t
5 define void @foo1(i32 %s, i32 %t) {
8 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[S:%.*]], [[T:%.*]]
9 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END6:%.*]]
11 ; CHECK-NEXT: call void @bar1(i32 [[S]], i32 [[T]])
12 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[S]], [[T]]
13 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END6]]
15 ; CHECK-NEXT: call void @bar2(i32 [[S]], i32 [[T]])
16 ; CHECK-NEXT: [[CMP3:%.*]] = icmp sle i32 [[S]], [[T]]
17 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END6]]
19 ; CHECK-NEXT: call void @bar3(i32 [[S]], i32 [[T]])
20 ; CHECK-NEXT: br label [[IF_END6]]
22 ; CHECK-NEXT: ret void
25 %cmp = icmp sge i32 %s, %t
26 br i1 %cmp, label %if.then, label %if.end6
29 call void @bar1(i32 %s, i32 %t)
30 %cmp1 = icmp ne i32 %s, %t
31 br i1 %cmp1, label %if.then2, label %if.end6
34 call void @bar2(i32 %s, i32 %t)
35 %cmp3 = icmp sle i32 %s, %t
36 br i1 %cmp3, label %if.then4, label %if.end6
39 call void @bar3(i32 %s, i32 %t)
46 ; s != t, s >= t, s <= t
47 define void @foo11(i32 %s, i32 %t) {
48 ; CHECK-LABEL: @foo11(
50 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[S:%.*]], [[T:%.*]]
51 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END6:%.*]]
53 ; CHECK-NEXT: call void @bar1(i32 [[S]], i32 [[T]])
54 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i32 [[S]], [[T]]
55 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END6]]
57 ; CHECK-NEXT: call void @bar2(i32 [[S]], i32 [[T]])
58 ; CHECK-NEXT: [[CMP3:%.*]] = icmp sle i32 [[S]], [[T]]
59 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END6]]
61 ; CHECK-NEXT: call void @bar3(i32 [[S]], i32 [[T]])
62 ; CHECK-NEXT: br label [[IF_END6]]
64 ; CHECK-NEXT: ret void
67 %cmp = icmp ne i32 %s, %t
68 br i1 %cmp, label %if.then, label %if.end6
71 call void @bar1(i32 %s, i32 %t)
72 %cmp1 = icmp sge i32 %s, %t
73 br i1 %cmp1, label %if.then2, label %if.end6
76 call void @bar2(i32 %s, i32 %t)
77 %cmp3 = icmp sle i32 %s, %t
78 br i1 %cmp3, label %if.then4, label %if.end6
81 call void @bar3(i32 %s, i32 %t)
88 ; s >= t, t != s, s <= t
89 define void @foo2(i32 %s, i32 %t) {
92 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[S:%.*]], [[T:%.*]]
93 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END6:%.*]]
95 ; CHECK-NEXT: call void @bar1(i32 [[S]], i32 [[T]])
96 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[T]], [[S]]
97 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END6]]
99 ; CHECK-NEXT: call void @bar2(i32 [[S]], i32 [[T]])
100 ; CHECK-NEXT: [[CMP3:%.*]] = icmp sle i32 [[S]], [[T]]
101 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END6]]
103 ; CHECK-NEXT: call void @bar3(i32 [[S]], i32 [[T]])
104 ; CHECK-NEXT: br label [[IF_END6]]
106 ; CHECK-NEXT: ret void
109 %cmp = icmp sge i32 %s, %t
110 br i1 %cmp, label %if.then, label %if.end6
113 call void @bar1(i32 %s, i32 %t)
114 %cmp1 = icmp ne i32 %t, %s
115 br i1 %cmp1, label %if.then2, label %if.end6
118 call void @bar2(i32 %s, i32 %t)
119 %cmp3 = icmp sle i32 %s, %t
120 br i1 %cmp3, label %if.then4, label %if.end6
123 call void @bar3(i32 %s, i32 %t)
130 ; s != t, t <= s, s <= t
131 define void @foo21(i32 %s, i32 %t) {
132 ; CHECK-LABEL: @foo21(
134 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[S:%.*]], [[T:%.*]]
135 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END6:%.*]]
137 ; CHECK-NEXT: call void @bar1(i32 [[S]], i32 [[T]])
138 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i32 [[T]], [[S]]
139 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END6]]
141 ; CHECK-NEXT: call void @bar2(i32 [[S]], i32 [[T]])
142 ; CHECK-NEXT: [[CMP3:%.*]] = icmp sle i32 [[S]], [[T]]
143 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END6]]
145 ; CHECK-NEXT: call void @bar3(i32 [[S]], i32 [[T]])
146 ; CHECK-NEXT: br label [[IF_END6]]
148 ; CHECK-NEXT: ret void
151 %cmp = icmp ne i32 %s, %t
152 br i1 %cmp, label %if.then, label %if.end6
155 call void @bar1(i32 %s, i32 %t)
156 %cmp1 = icmp sle i32 %t, %s
157 br i1 %cmp1, label %if.then2, label %if.end6
160 call void @bar2(i32 %s, i32 %t)
161 %cmp3 = icmp sle i32 %s, %t
162 br i1 %cmp3, label %if.then4, label %if.end6
165 call void @bar3(i32 %s, i32 %t)
172 ; t <= s, t != s, s <= t
173 define void @foo3(i32 %s, i32 %t) {
174 ; CHECK-LABEL: @foo3(
176 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[T:%.*]], [[S:%.*]]
177 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END6:%.*]]
179 ; CHECK-NEXT: call void @bar1(i32 [[S]], i32 [[T]])
180 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[T]], [[S]]
181 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END6]]
183 ; CHECK-NEXT: call void @bar2(i32 [[S]], i32 [[T]])
184 ; CHECK-NEXT: [[CMP3:%.*]] = icmp sle i32 [[S]], [[T]]
185 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END6]]
187 ; CHECK-NEXT: call void @bar3(i32 [[S]], i32 [[T]])
188 ; CHECK-NEXT: br label [[IF_END6]]
190 ; CHECK-NEXT: ret void
193 %cmp = icmp sle i32 %t, %s
194 br i1 %cmp, label %if.then, label %if.end6
197 call void @bar1(i32 %s, i32 %t)
198 %cmp1 = icmp ne i32 %t, %s
199 br i1 %cmp1, label %if.then2, label %if.end6
202 call void @bar2(i32 %s, i32 %t)
203 %cmp3 = icmp sle i32 %s, %t
204 br i1 %cmp3, label %if.then4, label %if.end6
207 call void @bar3(i32 %s, i32 %t)
214 ; t != s, t <= s, s <= t
215 define void @foo31(i32 %s, i32 %t) {
216 ; CHECK-LABEL: @foo31(
218 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[T:%.*]], [[S:%.*]]
219 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END6:%.*]]
221 ; CHECK-NEXT: call void @bar1(i32 [[S]], i32 [[T]])
222 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i32 [[T]], [[S]]
223 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END6]]
225 ; CHECK-NEXT: call void @bar2(i32 [[S]], i32 [[T]])
226 ; CHECK-NEXT: [[CMP3:%.*]] = icmp sle i32 [[S]], [[T]]
227 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_END6]]
229 ; CHECK-NEXT: call void @bar3(i32 [[S]], i32 [[T]])
230 ; CHECK-NEXT: br label [[IF_END6]]
232 ; CHECK-NEXT: ret void
235 %cmp = icmp ne i32 %t, %s
236 br i1 %cmp, label %if.then, label %if.end6
239 call void @bar1(i32 %s, i32 %t)
240 %cmp1 = icmp sle i32 %t, %s
241 br i1 %cmp1, label %if.then2, label %if.end6
244 call void @bar2(i32 %s, i32 %t)
245 %cmp3 = icmp sle i32 %s, %t
246 br i1 %cmp3, label %if.then4, label %if.end6
249 call void @bar3(i32 %s, i32 %t)
256 declare void @bar1(i32, i32)
257 declare void @bar2(i32, i32)
258 declare void @bar3(i32, i32)