aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/GlobalOpt
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-03-28 14:50:09 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-03-28 14:50:09 +0000
commitc1ea16ec4339a9746f436c6f2f5b08197f309343 (patch)
tree6fc94a8a0bda0fddeee448e76ce7f5ad98cd16b6 /test/Transforms/GlobalOpt
parent9b58464330f45dcf6fe621a40f4bc8617169586e (diff)
GlobalOpt: If we have an inbounds GEP from a ConstantAggregateZero global that we just determined to be constant, replace all loads from it with a zero value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GlobalOpt')
-rw-r--r--test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll b/test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll
new file mode 100644
index 0000000000..d613601e8d
--- /dev/null
+++ b/test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll
@@ -0,0 +1,11 @@
+; RUN: opt < %s -S -globalopt | FileCheck %s
+
+@zero = internal global [10 x i32] zeroinitializer
+
+define i32 @test1(i64 %idx) nounwind {
+ %arrayidx = getelementptr inbounds [10 x i32]* @zero, i64 0, i64 %idx
+ %l = load i32* %arrayidx
+ ret i32 %l
+; CHECK: @test1
+; CHECK: ret i32 0
+}