Skip to content

Commit cb3b5f0

Browse files
committed
[ConstraintElimination] Add multi-dimension GEP tests.
Add a set of interesting test cases with multi-dimensional GEPs for upcoming patches.
1 parent f21cc55 commit cb3b5f0

File tree

3 files changed

+691
-134
lines changed

3 files changed

+691
-134
lines changed
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -constraint-elimination -S %s | FileCheck %s
3+
4+
define void @pointer.to.array.test.ult.true.due.to.first.dimension([10 x i8]* %start, i8* %high) {
5+
; CHECK-LABEL: @pointer.to.array.test.ult.true.due.to.first.dimension(
6+
; CHECK-NEXT: entry:
7+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 9, i64 3
8+
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[ADD_PTR_I]], [[HIGH:%.*]]
9+
; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
10+
; CHECK: if.then:
11+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 5, i64 0
12+
; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8* [[START_0]], [[HIGH]]
13+
; CHECK-NEXT: call void @use(i1 [[C_0]])
14+
; CHECK-NEXT: ret void
15+
; CHECK: if.end:
16+
; CHECK-NEXT: ret void
17+
;
18+
entry:
19+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 9, i64 3
20+
%c.1 = icmp ule i8* %add.ptr.i, %high
21+
br i1 %c.1, label %if.then, label %if.end
22+
23+
if.then: ; preds = %entry
24+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 5, i64 0
25+
%c.0 = icmp ult i8* %start.0, %high
26+
call void @use(i1 %c.0)
27+
28+
ret void
29+
30+
if.end: ; preds = %entry
31+
ret void
32+
}
33+
34+
define void @pointer.to.array.test.ult.unknown.due.to.first.dimension([10 x i8]* %start, i8* %high) {
35+
; CHECK-LABEL: @pointer.to.array.test.ult.unknown.due.to.first.dimension(
36+
; CHECK-NEXT: entry:
37+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 5, i64 3
38+
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[ADD_PTR_I]], [[HIGH:%.*]]
39+
; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
40+
; CHECK: if.then:
41+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 10, i64 0
42+
; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8* [[START_0]], [[HIGH]]
43+
; CHECK-NEXT: call void @use(i1 [[C_0]])
44+
; CHECK-NEXT: ret void
45+
; CHECK: if.end:
46+
; CHECK-NEXT: ret void
47+
;
48+
entry:
49+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 5, i64 3
50+
%c.1 = icmp ule i8* %add.ptr.i, %high
51+
br i1 %c.1, label %if.then, label %if.end
52+
53+
if.then: ; preds = %entry
54+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 10, i64 0
55+
%c.0 = icmp ult i8* %start.0, %high
56+
call void @use(i1 %c.0)
57+
58+
ret void
59+
60+
if.end: ; preds = %entry
61+
ret void
62+
}
63+
64+
define void @pointer.to.array.test.ult.true.due.to.second.dimension([10 x i8]* %start, i8* %high) {
65+
; CHECK-LABEL: @pointer.to.array.test.ult.true.due.to.second.dimension(
66+
; CHECK-NEXT: entry:
67+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 5, i64 1
68+
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[ADD_PTR_I]], [[HIGH:%.*]]
69+
; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
70+
; CHECK: if.then:
71+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 5, i64 0
72+
; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8* [[START_0]], [[HIGH]]
73+
; CHECK-NEXT: call void @use(i1 [[C_0]])
74+
; CHECK-NEXT: ret void
75+
; CHECK: if.end:
76+
; CHECK-NEXT: ret void
77+
;
78+
entry:
79+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 5, i64 1
80+
%c.1 = icmp ule i8* %add.ptr.i, %high
81+
br i1 %c.1, label %if.then, label %if.end
82+
83+
if.then: ; preds = %entry
84+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 5, i64 0
85+
%c.0 = icmp ult i8* %start.0, %high
86+
call void @use(i1 %c.0)
87+
88+
ret void
89+
90+
if.end: ; preds = %entry
91+
ret void
92+
}
93+
94+
define void @pointer.to.array.test.ult.unknown.to.second.dimension([10 x i8]* %start, i8* %high) {
95+
; CHECK-LABEL: @pointer.to.array.test.ult.unknown.to.second.dimension(
96+
; CHECK-NEXT: entry:
97+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 5, i64 0
98+
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[ADD_PTR_I]], [[HIGH:%.*]]
99+
; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
100+
; CHECK: if.then:
101+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 5, i64 1
102+
; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8* [[START_0]], [[HIGH]]
103+
; CHECK-NEXT: call void @use(i1 [[C_0]])
104+
; CHECK-NEXT: ret void
105+
; CHECK: if.end:
106+
; CHECK-NEXT: ret void
107+
;
108+
entry:
109+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 5, i64 0
110+
%c.1 = icmp ule i8* %add.ptr.i, %high
111+
br i1 %c.1, label %if.then, label %if.end
112+
113+
if.then: ; preds = %entry
114+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 5, i64 1
115+
%c.0 = icmp ult i8* %start.0, %high
116+
call void @use(i1 %c.0)
117+
118+
ret void
119+
120+
if.end: ; preds = %entry
121+
ret void
122+
}
123+
124+
define void @pointer.to.array.test.not.uge.ult([10 x i8]* %start, i8* %high) {
125+
; CHECK-LABEL: @pointer.to.array.test.not.uge.ult(
126+
; CHECK-NEXT: entry:
127+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
128+
; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
129+
; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
130+
; CHECK: if.then:
131+
; CHECK-NEXT: ret void
132+
; CHECK: if.end:
133+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 10, i64 0
134+
; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8* [[START_0]], [[HIGH]]
135+
; CHECK-NEXT: call void @use(i1 [[C_0]])
136+
; CHECK-NEXT: ret void
137+
;
138+
entry:
139+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
140+
%c.1 = icmp uge i8* %add.ptr.i, %high
141+
br i1 %c.1, label %if.then, label %if.end
142+
143+
if.then: ; preds = %entry
144+
ret void
145+
146+
if.end: ; preds = %entry
147+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 10, i64 0
148+
%c.0 = icmp ult i8* %start.0, %high
149+
call void @use(i1 %c.0)
150+
ret void
151+
}
152+
153+
define void @pointer.to.array.test.not.uge.ule([10 x i8]* %start, i8* %high) {
154+
; CHECK-LABEL: @pointer.to.array.test.not.uge.ule(
155+
; CHECK-NEXT: entry:
156+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
157+
; CHECK-NEXT: [[C:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
158+
; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
159+
; CHECK: if.then:
160+
; CHECK-NEXT: ret void
161+
; CHECK: if.end:
162+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 10, i64 0
163+
; CHECK-NEXT: [[C_0:%.*]] = icmp ule i8* [[START_0]], [[HIGH]]
164+
; CHECK-NEXT: call void @use(i1 [[C_0]])
165+
; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 2, i64 1
166+
; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[START_1]], [[HIGH]]
167+
; CHECK-NEXT: call void @use(i1 [[C_1]])
168+
; CHECK-NEXT: ret void
169+
;
170+
entry:
171+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
172+
%c = icmp uge i8* %add.ptr.i, %high
173+
br i1 %c, label %if.then, label %if.end
174+
175+
if.then: ; preds = %entry
176+
ret void
177+
178+
if.end: ; preds = %entry
179+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 10, i64 0
180+
%c.0 = icmp ule i8* %start.0, %high
181+
call void @use(i1 %c.0)
182+
%start.1 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 2, i64 1
183+
%c.1 = icmp ule i8* %start.1, %high
184+
call void @use(i1 %c.1)
185+
ret void
186+
}
187+
188+
define void @pointer.to.array.test.not.uge.ugt([10 x i8]* %start, i8* %high) {
189+
; CHECK-LABEL: @pointer.to.array.test.not.uge.ugt(
190+
; CHECK-NEXT: entry:
191+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
192+
; CHECK-NEXT: [[C:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
193+
; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
194+
; CHECK: if.then:
195+
; CHECK-NEXT: ret void
196+
; CHECK: if.end:
197+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 3, i64 0
198+
; CHECK-NEXT: [[C_0:%.*]] = icmp ugt i8* [[START_0]], [[HIGH]]
199+
; CHECK-NEXT: call void @use(i1 [[C_0]])
200+
; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 3, i64 1
201+
; CHECK-NEXT: [[C_1:%.*]] = icmp ugt i8* [[START_1]], [[HIGH]]
202+
; CHECK-NEXT: call void @use(i1 [[C_1]])
203+
; CHECK-NEXT: ret void
204+
;
205+
entry:
206+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
207+
%c = icmp uge i8* %add.ptr.i, %high
208+
br i1 %c, label %if.then, label %if.end
209+
210+
if.then: ; preds = %entry
211+
ret void
212+
213+
if.end: ; preds = %entry
214+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 3, i64 0
215+
%c.0 = icmp ugt i8* %start.0, %high
216+
call void @use(i1 %c.0)
217+
218+
%start.1 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 3, i64 1
219+
%c.1 = icmp ugt i8* %start.1, %high
220+
call void @use(i1 %c.1)
221+
ret void
222+
}
223+
224+
define void @pointer.to.array.test.not.uge.uge([10 x i8]* %start, i8* %high) {
225+
; CHECK-LABEL: @pointer.to.array.test.not.uge.uge(
226+
; CHECK-NEXT: entry:
227+
; CHECK-NEXT: [[ADD_PTR_I:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START:%.*]], i64 1, i64 3
228+
; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[ADD_PTR_I]], [[HIGH:%.*]]
229+
; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
230+
; CHECK: if.then:
231+
; CHECK-NEXT: ret void
232+
; CHECK: if.end:
233+
; CHECK-NEXT: [[START_0:%.*]] = getelementptr inbounds [10 x i8], [10 x i8]* [[START]], i64 3, i64 0
234+
; CHECK-NEXT: [[C_0:%.*]] = icmp uge i8* [[START_0]], [[HIGH]]
235+
; CHECK-NEXT: call void @use(i1 [[C_0]])
236+
; CHECK-NEXT: ret void
237+
;
238+
entry:
239+
%add.ptr.i = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 1, i64 3
240+
%c.1 = icmp uge i8* %add.ptr.i, %high
241+
br i1 %c.1, label %if.then, label %if.end
242+
243+
if.then: ; preds = %entry
244+
ret void
245+
246+
if.end: ; preds = %entry
247+
%start.0 = getelementptr inbounds [10 x i8], [10 x i8]* %start, i64 3, i64 0
248+
%c.0 = icmp uge i8* %start.0, %high
249+
call void @use(i1 %c.0)
250+
251+
ret void
252+
}
253+
254+
declare void @use(i1)

0 commit comments

Comments
 (0)