Skip to content

Commit

Permalink
[InstCombine] Add extra test for icmp of gep fold (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jan 2, 2024
1 parent 795c989 commit fc9dbc9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions llvm/test/Transforms/InstCombine/icmp-gep.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ target datalayout = "e-p:64:64:64-p1:16:16:16-p2:32:32:32-p3:64:64:64-i1:8:8-i8:

declare ptr @getptr()
declare void @use(ptr)
declare void @use.i1(i1)

define i1 @eq_base(ptr %x, i64 %y) {
; CHECK-LABEL: @eq_base(
Expand Down Expand Up @@ -443,6 +444,29 @@ define i1 @test60_extra_use_const_operands_no_inbounds(ptr %foo, i64 %i, i64 %j)
ret i1 %cmp
}

define void @test60_extra_use_fold(ptr %foo, i64 %start.idx, i64 %end.offset) {
; CHECK-LABEL: @test60_extra_use_fold(
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, ptr [[FOO:%.*]], i64 [[START_IDX:%.*]]
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i8, ptr [[FOO]], i64 [[END_OFFSET:%.*]]
; CHECK-NEXT: call void @use(ptr [[GEP1]])
; CHECK-NEXT: call void @use(ptr [[GEP2]])
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[GEP1]], [[GEP2]]
; CHECK-NEXT: call void @use.i1(i1 [[CMP1]])
; CHECK-NEXT: [[CMP2:%.*]] = icmp ult ptr [[GEP1]], [[GEP2]]
; CHECK-NEXT: call void @use.i1(i1 [[CMP2]])
; CHECK-NEXT: ret void
;
%gep1 = getelementptr inbounds i32, ptr %foo, i64 %start.idx
%gep2 = getelementptr inbounds i8, ptr %foo, i64 %end.offset
call void @use(ptr %gep1)
call void @use(ptr %gep2)
%cmp1 = icmp eq ptr %gep1, %gep2
call void @use.i1(i1 %cmp1)
%cmp2 = icmp ult ptr %gep1, %gep2
call void @use.i1(i1 %cmp2)
ret void
}

define i1 @test_scalable_same(ptr %x) {
; CHECK-LABEL: @test_scalable_same(
; CHECK-NEXT: ret i1 false
Expand Down

0 comments on commit fc9dbc9

Please sign in to comment.