[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Apr 13 22:29:01 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.189 -> 1.190
---
Log message:
ADd a trivial instcombine: load null -> null
---
Diffs of the changes: (+5 -2)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.189 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.190
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.189 Sat Apr 10 20:39:19 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Apr 13 22:28:36 2004
@@ -2853,8 +2853,11 @@
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))
More information about the llvm-commits
mailing list