1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 define void @pointer.to.array.test.ult.true.due.to.first.dimension(ptr %start, ptr %high) {
5 ; CHECK-LABEL: @pointer.to.array.test.ult.true.due.to.first.dimension(
7 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 9, i64 3
8 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule ptr [[ADD_PTR_I]], [[HIGH:%.*]]
9 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
11 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 5, i64 0
12 ; CHECK-NEXT: call void @use(i1 true)
13 ; CHECK-NEXT: ret void
15 ; CHECK-NEXT: ret void
18 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 9, i64 3
19 %c.1 = icmp ule ptr %add.ptr.i, %high
20 br i1 %c.1, label %if.then, label %if.end
22 if.then: ; preds = %entry
23 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 5, i64 0
24 %c.0 = icmp ult ptr %start.0, %high
25 call void @use(i1 %c.0)
28 if.end: ; preds = %entry
32 define void @pointer.to.array.test.ult.unknown.due.to.first.dimension(ptr %start, ptr %high) {
33 ; CHECK-LABEL: @pointer.to.array.test.ult.unknown.due.to.first.dimension(
35 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 5, i64 3
36 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule ptr [[ADD_PTR_I]], [[HIGH:%.*]]
37 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
39 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 10, i64 0
40 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult ptr [[START_0]], [[HIGH]]
41 ; CHECK-NEXT: call void @use(i1 [[C_0]])
42 ; CHECK-NEXT: ret void
44 ; CHECK-NEXT: ret void
47 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 5, i64 3
48 %c.1 = icmp ule ptr %add.ptr.i, %high
49 br i1 %c.1, label %if.then, label %if.end
51 if.then: ; preds = %entry
52 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 10, i64 0
53 %c.0 = icmp ult ptr %start.0, %high
54 call void @use(i1 %c.0)
57 if.end: ; preds = %entry
61 define void @pointer.to.array.test.ult.true.due.to.second.dimension(ptr %start, ptr %high) {
62 ; CHECK-LABEL: @pointer.to.array.test.ult.true.due.to.second.dimension(
64 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 5, i64 1
65 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule ptr [[ADD_PTR_I]], [[HIGH:%.*]]
66 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
68 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 5, i64 0
69 ; CHECK-NEXT: call void @use(i1 true)
70 ; CHECK-NEXT: ret void
72 ; CHECK-NEXT: ret void
75 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 5, i64 1
76 %c.1 = icmp ule ptr %add.ptr.i, %high
77 br i1 %c.1, label %if.then, label %if.end
79 if.then: ; preds = %entry
80 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 5, i64 0
81 %c.0 = icmp ult ptr %start.0, %high
82 call void @use(i1 %c.0)
85 if.end: ; preds = %entry
89 define void @pointer.to.array.test.ult.unknown.to.second.dimension(ptr %start, ptr %high) {
90 ; CHECK-LABEL: @pointer.to.array.test.ult.unknown.to.second.dimension(
92 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 5, i64 0
93 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule ptr [[ADD_PTR_I]], [[HIGH:%.*]]
94 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
96 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 5, i64 1
97 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult ptr [[START_0]], [[HIGH]]
98 ; CHECK-NEXT: call void @use(i1 [[C_0]])
99 ; CHECK-NEXT: ret void
101 ; CHECK-NEXT: ret void
104 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 5, i64 0
105 %c.1 = icmp ule ptr %add.ptr.i, %high
106 br i1 %c.1, label %if.then, label %if.end
108 if.then: ; preds = %entry
109 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 5, i64 1
110 %c.0 = icmp ult ptr %start.0, %high
111 call void @use(i1 %c.0)
114 if.end: ; preds = %entry
118 define void @pointer.to.array.test.not.uge.ult(ptr %start, ptr %high) {
119 ; CHECK-LABEL: @pointer.to.array.test.not.uge.ult(
121 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 1, i64 3
122 ; CHECK-NEXT: [[C_1:%.*]] = icmp uge ptr [[ADD_PTR_I]], [[HIGH:%.*]]
123 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
125 ; CHECK-NEXT: ret void
127 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 10, i64 0
128 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult ptr [[START_0]], [[HIGH]]
129 ; CHECK-NEXT: call void @use(i1 [[C_0]])
130 ; CHECK-NEXT: ret void
133 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 1, i64 3
134 %c.1 = icmp uge ptr %add.ptr.i, %high
135 br i1 %c.1, label %if.then, label %if.end
137 if.then: ; preds = %entry
140 if.end: ; preds = %entry
141 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 10, i64 0
142 %c.0 = icmp ult ptr %start.0, %high
143 call void @use(i1 %c.0)
147 define void @pointer.to.array.test.not.uge.ule(ptr %start, ptr %high) {
148 ; CHECK-LABEL: @pointer.to.array.test.not.uge.ule(
150 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 1, i64 3
151 ; CHECK-NEXT: [[C:%.*]] = icmp uge ptr [[ADD_PTR_I]], [[HIGH:%.*]]
152 ; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
154 ; CHECK-NEXT: ret void
156 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 10, i64 0
157 ; CHECK-NEXT: [[C_0:%.*]] = icmp ule ptr [[START_0]], [[HIGH]]
158 ; CHECK-NEXT: call void @use(i1 [[C_0]])
159 ; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 2, i64 1
160 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule ptr [[START_1]], [[HIGH]]
161 ; CHECK-NEXT: call void @use(i1 [[C_1]])
162 ; CHECK-NEXT: ret void
165 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 1, i64 3
166 %c = icmp uge ptr %add.ptr.i, %high
167 br i1 %c, label %if.then, label %if.end
169 if.then: ; preds = %entry
172 if.end: ; preds = %entry
173 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 10, i64 0
174 %c.0 = icmp ule ptr %start.0, %high
175 call void @use(i1 %c.0)
176 %start.1 = getelementptr inbounds [10 x i8], ptr %start, i64 2, i64 1
177 %c.1 = icmp ule ptr %start.1, %high
178 call void @use(i1 %c.1)
182 define void @pointer.to.array.test.not.uge.ugt(ptr %start, ptr %high) {
183 ; CHECK-LABEL: @pointer.to.array.test.not.uge.ugt(
185 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 1, i64 3
186 ; CHECK-NEXT: [[C:%.*]] = icmp uge ptr [[ADD_PTR_I]], [[HIGH:%.*]]
187 ; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
189 ; CHECK-NEXT: ret void
191 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 3, i64 0
192 ; CHECK-NEXT: [[C_0:%.*]] = icmp ugt ptr [[START_0]], [[HIGH]]
193 ; CHECK-NEXT: call void @use(i1 [[C_0]])
194 ; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 3, i64 1
195 ; CHECK-NEXT: [[C_1:%.*]] = icmp ugt ptr [[START_1]], [[HIGH]]
196 ; CHECK-NEXT: call void @use(i1 [[C_1]])
197 ; CHECK-NEXT: ret void
200 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 1, i64 3
201 %c = icmp uge ptr %add.ptr.i, %high
202 br i1 %c, label %if.then, label %if.end
204 if.then: ; preds = %entry
207 if.end: ; preds = %entry
208 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 3, i64 0
209 %c.0 = icmp ugt ptr %start.0, %high
210 call void @use(i1 %c.0)
211 %start.1 = getelementptr inbounds [10 x i8], ptr %start, i64 3, i64 1
212 %c.1 = icmp ugt ptr %start.1, %high
213 call void @use(i1 %c.1)
217 define void @pointer.to.array.test.not.uge.uge(ptr %start, ptr %high) {
218 ; CHECK-LABEL: @pointer.to.array.test.not.uge.uge(
220 ; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], ptr [[START:%.*]], i64 1, i64 3
221 ; CHECK-NEXT: [[C_1:%.*]] = icmp uge ptr [[ADD_PTR_I]], [[HIGH:%.*]]
222 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
224 ; CHECK-NEXT: ret void
226 ; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], ptr [[START]], i64 3, i64 0
227 ; CHECK-NEXT: [[C_0:%.*]] = icmp uge ptr [[START_0]], [[HIGH]]
228 ; CHECK-NEXT: call void @use(i1 [[C_0]])
229 ; CHECK-NEXT: ret void
232 %add.ptr.i = getelementptr inbounds [10 x i8], ptr %start, i64 1, i64 3
233 %c.1 = icmp uge ptr %add.ptr.i, %high
234 br i1 %c.1, label %if.then, label %if.end
236 if.then: ; preds = %entry
239 if.end: ; preds = %entry
240 %start.0 = getelementptr inbounds [10 x i8], ptr %start, i64 3, i64 0
241 %c.0 = icmp uge ptr %start.0, %high
242 call void @use(i1 %c.0)
246 declare void @use(i1)