diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-14 03:28:36 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-14 03:28:36 +0000 |
commit | d9955aaa61adbcb7118d4d090d00a4c6a7bbadf1 (patch) | |
tree | 47d593dd6f55b476c7b3b87debcdb99e849b9dbe /lib/Transforms/Scalar | |
parent | 098e945fbdd7eac94cc3c851eae83fcdd7c80726 (diff) | |
download | external_llvm-d9955aaa61adbcb7118d4d090d00a4c6a7bbadf1.zip external_llvm-d9955aaa61adbcb7118d4d090d00a4c6a7bbadf1.tar.gz external_llvm-d9955aaa61adbcb7118d4d090d00a4c6a7bbadf1.tar.bz2 |
ADd a trivial instcombine: load null -> null
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index af85c5f..fe13a6b 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2853,8 +2853,11 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { Value *Op = LI.getOperand(0); if (LI.isVolatile()) return 0; - if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Op)) - Op = CPR->getValue(); + if (Constant *C = dyn_cast<Constant>(Op)) + if (C->isNullValue()) // load null -> 0 + return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType())); + else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) + Op = CPR->getValue(); // Instcombine load (constant global) into the value loaded... if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op)) |