Skip to content

Commit

Permalink
[InstCombine] Add multiuse test for D106352
Browse files Browse the repository at this point in the history
  • Loading branch information
RKSimon committed Jul 21, 2021
1 parent bb4f7b9 commit 59db3a5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions llvm/test/Transforms/InstCombine/select-gep.ll
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,22 @@ define <2 x i64*> @test5(i64* %p1, i64* %p2, <2 x i64> %idx, <2 x i1> %cc) {
%select = select <2 x i1> %cc, <2 x i64*> %gep1, <2 x i64*> %gep2
ret <2 x i64*> %select
}

; PR51069 - multiple uses
define i32* @test6(i32* %p, i64 %x, i64 %y) {
; CHECK-LABEL: @test6(
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 [[X:%.*]]
; CHECK-NEXT: [[ICMP:%.*]] = icmp ugt i64 [[X]], [[Y:%.*]]
; CHECK-NEXT: [[SEL_IDX:%.*]] = select i1 [[ICMP]], i64 [[Y]], i64 0
; CHECK-NEXT: [[SEL:%.*]] = getelementptr i32, i32* [[GEP1]], i64 [[SEL_IDX]]
; CHECK-NEXT: call void @use_i32p(i32* [[GEP1]])
; CHECK-NEXT: ret i32* [[SEL]]
;
%gep1 = getelementptr inbounds i32, i32* %p, i64 %x
%gep2 = getelementptr inbounds i32, i32* %gep1, i64 %y
%icmp = icmp ugt i64 %x, %y
%sel = select i1 %icmp, i32* %gep2, i32* %gep1
call void @use_i32p(i32* %gep1)
ret i32* %sel
}
declare void @use_i32p(i32*)

0 comments on commit 59db3a5

Please sign in to comment.