ADd a trivial instcombine: load null -> null

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-04-14 03:28:36 +00:00
parent 098e945fbd
commit d9955aaa61

View File

@ -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))