From 3be4acbaa35607131411e94829185227a061e639 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 3 Oct 2021 13:26:14 +0200 Subject: [PATCH] [InstSimplify] Add additional load from constant test (NFC) 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]). --- llvm/test/Transforms/InstSimplify/ConstProp/loads.ll | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/loads.ll b/llvm/test/Transforms/InstSimplify/ConstProp/loads.ll index 6f25b9f8d10c..c5ada729b31a 100644 --- a/llvm/test/Transforms/InstSimplify/ConstProp/loads.ll +++ b/llvm/test/Transforms/InstSimplify/ConstProp/loads.ll @@ -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 +}