summaryrefslogtreecommitdiff
path: root/test/Transforms/GlobalOpt/constantfold-initializers.ll
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-11-23 16:22:21 +0000
committerDan Gohman <gohman@apple.com>2009-11-23 16:22:21 +0000
commit01b97dd01eec1197d79fceb7229f5ec233994de3 (patch)
tree88196a1f71041f2236951d786a30477f28c9262c /test/Transforms/GlobalOpt/constantfold-initializers.ll
parent8f3817f505029e97d28c54548069d5bbaa9d5527 (diff)
downloadllvm-01b97dd01eec1197d79fceb7229f5ec233994de3.tar.gz
llvm-01b97dd01eec1197d79fceb7229f5ec233994de3.tar.bz2
llvm-01b97dd01eec1197d79fceb7229f5ec233994de3.tar.xz
Make ConstantFoldConstantExpression recursively visit the entire
ConstantExpr, not just the top-level operator. This allows it to fold many more constants. Also, make GlobalOpt call ConstantFoldConstantExpression on GlobalVariable initializers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GlobalOpt/constantfold-initializers.ll')
-rw-r--r--test/Transforms/GlobalOpt/constantfold-initializers.ll8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/Transforms/GlobalOpt/constantfold-initializers.ll b/test/Transforms/GlobalOpt/constantfold-initializers.ll
new file mode 100644
index 0000000000..834bd0012e
--- /dev/null
+++ b/test/Transforms/GlobalOpt/constantfold-initializers.ll
@@ -0,0 +1,8 @@
+; RUN: opt < %s -S -globalopt | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+
+@.str91250 = global [3 x i8] zeroinitializer
+
+; CHECK: @A = global i1 false
+@A = global i1 icmp ne (i64 sub nsw (i64 ptrtoint (i8* getelementptr inbounds ([3 x i8]* @.str91250, i64 0, i64 1) to i64), i64 ptrtoint ([3 x i8]* @.str91250 to i64)), i64 1)