xref: /llvm-project/llvm/test/Transforms/InstCombine/store-load-unaliased-gep.ll (revision 0676acb6fd8d5e22fde16e6ec977ceac08427ab0)
1; RUN: opt -passes=instcombine %s -S 2>&1 | FileCheck %s
2; RUN: opt -aa-pipeline=basic-aa -passes=instcombine %s -S 2>&1 | FileCheck %s
3
4; Checking successful store-load optimization of array length.
5; Function below should deduce just to "return length".
6; Doable only if instcombine has access to alias-analysis.
7
8define i32 @test1(i32 %length) {
9; CHECK-LABEL: entry:
10entry:
11  %array = alloca i32, i32 2
12  ; CHECK-NOT: %array
13
14  %value_gep = getelementptr inbounds i32, ptr %array, i32 1
15  store i32 %length, ptr %array
16  store i32 0, ptr %value_gep
17  %loaded_length = load i32, ptr %array
18  ; CHECK-NOT: %loaded_length = load i32
19
20  ret i32 %loaded_length
21  ; CHECK: ret i32 %length
22}
23