Since 'load null' is undefined, we can make it do whatever we want. Returning

a zero value is the most likely way to cause further simplification, so we do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12197 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-03-07 22:16:24 +00:00
parent f8338c4375
commit c76d80342e

View File

@ -713,6 +713,12 @@ void SCCP::visitLoadInst(LoadInst &I) {
if (PtrVal.isUndefined()) return; // The pointer is not resolved yet!
if (PtrVal.isConstant() && !I.isVolatile()) {
Value *Ptr = PtrVal.getConstant();
if (isa<ConstantPointerNull>(Ptr)) {
// load null -> null
markConstant(IV, &I, Constant::getNullValue(I.getType()));
return;
}
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Ptr))
Ptr = CPR->getValue();