forked from OSchip/llvm-project
ADd a trivial instcombine: load null -> null
llvm-svn: 12940
This commit is contained in:
parent
0dc099c2b5
commit
6679e46b59
|
@ -2853,8 +2853,11 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
|
||||||
Value *Op = LI.getOperand(0);
|
Value *Op = LI.getOperand(0);
|
||||||
if (LI.isVolatile()) return 0;
|
if (LI.isVolatile()) return 0;
|
||||||
|
|
||||||
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Op))
|
if (Constant *C = dyn_cast<Constant>(Op))
|
||||||
Op = CPR->getValue();
|
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...
|
// Instcombine load (constant global) into the value loaded...
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
|
||||||
|
|
Loading…
Reference in New Issue