aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-07 22:16:24 +0000
committerChris Lattner <sabre@nondot.org>2004-03-07 22:16:24 +0000
commitc76d80342e229a86bf3f780c797e29d197363bc4 (patch)
treee1bedd18ec2aef284c397cda1463e6bf91d8ce48 /lib/Transforms/Scalar
parentf8338c4375b25cbb61b5ea38b2e0006efa554db7 (diff)
downloadexternal_llvm-c76d80342e229a86bf3f780c797e29d197363bc4.zip
external_llvm-c76d80342e229a86bf3f780c797e29d197363bc4.tar.gz
external_llvm-c76d80342e229a86bf3f780c797e29d197363bc4.tar.bz2
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
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 8304e2e..56cb2cc 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<ConstantPointerNull>(Ptr)) {
+ // load null -> null
+ markConstant(IV, &I, Constant::getNullValue(I.getType()));
+ return;
+ }
+
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Ptr))
Ptr = CPR->getValue();