summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-14 03:28:36 +0000
committerChris Lattner <sabre@nondot.org>2004-04-14 03:28:36 +0000
commit6679e46b592fb8a9976b88b8e2ea35d829c00339 (patch)
tree3402bcda2a3cab5ba92655f6f9c9cb728cea8042 /llvm/lib
parent0dc099c2b52de20f8dffd1e0bfa7b16c250efa34 (diff)
downloadbcm5719-llvm-6679e46b592fb8a9976b88b8e2ea35d829c00339.tar.gz
bcm5719-llvm-6679e46b592fb8a9976b88b8e2ea35d829c00339.zip
ADd a trivial instcombine: load null -> null
llvm-svn: 12940
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index af85c5fdde9..fe13a6ba540 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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))
OpenPOWER on IntegriCloud