Skip to content

Commit

Permalink
[InstCombine] add test for gep (select),... (PR45084); NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
rotateright committed Mar 7, 2020
1 parent 498e37e commit 564f5ee
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions llvm/test/Transforms/InstCombine/getelementptr.ll
Expand Up @@ -1208,3 +1208,19 @@ define i32* @test_gep_inbounds_of_gep(i32* %base) {
%ptr2 = getelementptr inbounds i32, i32* %ptr1, i64 4
ret i32* %ptr2
}

%struct.f = type { i32 }

@g0 = internal unnamed_addr constant %struct.f zeroinitializer, align 4
@g1 = internal unnamed_addr constant %struct.f { i32 -1 }, align 4

define i32* @PR45084(i1 %cond) {
; CHECK-LABEL: @PR45084(
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], %struct.f* @g0, %struct.f* @g1
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds [[STRUCT_F:%.*]], %struct.f* [[SEL]], i64 0, i32 0
; CHECK-NEXT: ret i32* [[GEP]]
;
%sel = select i1 %cond, %struct.f* @g0, %struct.f* @g1
%gep = getelementptr inbounds %struct.f, %struct.f* %sel, i64 0, i32 0
ret i32* %gep
}

0 comments on commit 564f5ee

Please sign in to comment.