From: Chris Lattner Date: Sun, 7 Mar 2004 22:16:24 +0000 (+0000) Subject: Since 'load null' is undefined, we can make it do whatever we want. Returning X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c76d80342e229a86bf3f780c797e29d197363bc4;p=oota-llvm.git 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 --- diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 8304e2e823b..56cb2cc7701 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -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(Ptr)) { + // load null -> null + markConstant(IV, &I, Constant::getNullValue(I.getType())); + return; + } + if (ConstantPointerRef *CPR = dyn_cast(Ptr)) Ptr = CPR->getValue();