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.

llvm-svn: 12197
This commit is contained in:
Chris Lattner 2004-03-07 22:16:24 +00:00
parent 0179360703
commit ca3b90f308

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();