Skip to content

Commit

Permalink
[InstSimplify] Add additional load from constant test (NFC)
Browse files Browse the repository at this point in the history
This case does not get folded, because the GEP indexes too deeply
(to the i8), making the bitcast logic not apply (on the [8 x i8]).
  • Loading branch information
nikic committed Oct 3, 2021
1 parent a834849 commit 3be4acb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions llvm/test/Transforms/InstSimplify/ConstProp/loads.ll
Expand Up @@ -261,3 +261,14 @@ define i32* @test_undef_aggregate() {
%v = load i32*, i32** bitcast ({i128}* @g10 to i32**)
ret i32* %v
}

@g11 = constant <{ [8 x i8], [8 x i8] }> <{ [8 x i8] undef, [8 x i8] zeroinitializer }>, align 4

define {}* @test_trailing_zero_gep_index() {
; CHECK-LABEL: @test_trailing_zero_gep_index(
; CHECK-NEXT: [[V:%.*]] = load {}*, {}** bitcast (i8* getelementptr inbounds (<{ [8 x i8], [8 x i8] }>, <{ [8 x i8], [8 x i8] }>* @g11, i64 0, i32 1, i64 0) to {}**), align 4
; CHECK-NEXT: ret {}* [[V]]
;
%v = load {}*, {}** bitcast (i8* getelementptr inbounds (<{ [8 x i8], [8 x i8] }>, <{ [8 x i8], [8 x i8] }>* @g11, i32 0, i32 1, i32 0) to {}**), align 4
ret {}* %v
}

0 comments on commit 3be4acb

Please sign in to comment.