xref: /llvm-project/llvm/test/Transforms/GlobalOpt/stored-once-through-gep.ll (revision d586bd5ca231a6022f439d4c6e43cfeeb53eb1d6)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -passes=globalopt < %s | FileCheck %s
3
4; The global is stored once through a trivial GEP instruction (rather than
5; GEP constant expression) here. We should still be able to optimize it.
6
7%s = type { i32 }
8
9@g = internal unnamed_addr global i32 undef
10
11; CHECK-NOT: @g =
12
13define void @store() {
14; CHECK-LABEL: @store(
15; CHECK-NEXT:    ret void
16;
17  store i32 1, ptr @g, align 4
18  ret void
19}
20
21define i32 @load() {
22; CHECK-LABEL: @load(
23; CHECK-NEXT:    call fastcc void @store()
24; CHECK-NEXT:    ret i32 1
25;
26  call fastcc void @store()
27  %v = load i32, ptr @g
28  ret i32 %v
29}
30