Skip to content

Commit 3cfb081

Browse files
committed
[InstCombine] Add icmp gep tests without inbounds (NFC)
1 parent e8ec42b commit 3cfb081

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

llvm/test/Transforms/InstCombine/icmp-gep.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,32 @@ define i1 @test60(ptr %foo, i64 %i, i64 %j) {
284284
ret i1 %cmp
285285
}
286286

287+
define i1 @test_gep_ult_no_inbounds(ptr %foo, i64 %i, i64 %j) {
288+
; CHECK-LABEL: @test_gep_ult_no_inbounds(
289+
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[FOO:%.*]], i64 [[I:%.*]]
290+
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[FOO]], i64 [[J:%.*]]
291+
; CHECK-NEXT: [[CMP:%.*]] = icmp ult ptr [[GEP1]], [[GEP2]]
292+
; CHECK-NEXT: ret i1 [[CMP]]
293+
;
294+
%gep1 = getelementptr i32, ptr %foo, i64 %i
295+
%gep2 = getelementptr i8, ptr %foo, i64 %j
296+
%cmp = icmp ult ptr %gep1, %gep2
297+
ret i1 %cmp
298+
}
299+
300+
define i1 @test_gep_eq_no_inbounds(ptr %foo, i64 %i, i64 %j) {
301+
; CHECK-LABEL: @test_gep_eq_no_inbounds(
302+
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[FOO:%.*]], i64 [[I:%.*]]
303+
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[FOO]], i64 [[J:%.*]]
304+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[GEP1]], [[GEP2]]
305+
; CHECK-NEXT: ret i1 [[CMP]]
306+
;
307+
%gep1 = getelementptr i32, ptr %foo, i64 %i
308+
%gep2 = getelementptr i8, ptr %foo, i64 %j
309+
%cmp = icmp eq ptr %gep1, %gep2
310+
ret i1 %cmp
311+
}
312+
287313
define i1 @test60_as1(ptr addrspace(1) %foo, i64 %i, i64 %j) {
288314
; CHECK-LABEL: @test60_as1(
289315
; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[I:%.*]] to i16

0 commit comments

Comments
 (0)