1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -constraint-elimination -S %s | FileCheck %s
3
4define 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;
18entry:
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
23if.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
30if.end:                                           ; preds = %entry
31  ret void
32}
33
34define 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;
48entry:
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
53if.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
60if.end:                                           ; preds = %entry
61  ret void
62}
63
64define 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;
78entry:
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
83if.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
90if.end:                                           ; preds = %entry
91  ret void
92}
93
94define 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;
108entry:
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
113if.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
120if.end:                                           ; preds = %entry
121  ret void
122}
123
124define 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;
138entry:
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
143if.then:                                          ; preds = %entry
144  ret void
145
146if.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
153define 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;
170entry:
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
175if.then:                                          ; preds = %entry
176  ret void
177
178if.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
188define 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;
205entry:
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
210if.then:                                          ; preds = %entry
211  ret void
212
213if.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
224define 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;
238entry:
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
243if.then:                                          ; preds = %entry
244  ret void
245
246if.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
254declare void @use(i1)
255