diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-30 20:06:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-30 20:06:40 +0000 |
commit | 8a67ac525ed874473f0cbe4fc4a02a2606bff7dd (patch) | |
tree | 4df770abeae240d773c6e7e5b80782511ff8d8ab /lib | |
parent | 2345d1d22e9b03b4149ddfdc16582cebc0a4bdfc (diff) | |
download | llvm-8a67ac525ed874473f0cbe4fc4a02a2606bff7dd.tar.gz llvm-8a67ac525ed874473f0cbe4fc4a02a2606bff7dd.tar.bz2 llvm-8a67ac525ed874473f0cbe4fc4a02a2606bff7dd.tar.xz |
add getPointerAddressSpace() to GEP instruction, use the method
in a few scalar xforms to simplify things.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80506 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SimplifyCFGPass.cpp | 2 |
3 files changed, 6 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 47e6f4d558..478068c95b 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11289,8 +11289,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(Op)) { const Value *GEPI0 = GEPI->getOperand(0); // TODO: Consider a target hook for valid address spaces for this xform. - if (isa<ConstantPointerNull>(GEPI0) && - cast<PointerType>(GEPI0->getType())->getAddressSpace() == 0) { + if (isa<ConstantPointerNull>(GEPI0) && GEPI->getPointerAddressSpace() == 0){ // Insert a new store to null instruction before the load to indicate // that this code is not reachable. We do this instead of inserting // an unreachable instruction directly because we cannot modify the @@ -11304,8 +11303,8 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { if (Constant *C = dyn_cast<Constant>(Op)) { // load null/undef -> undef // TODO: Consider a target hook for valid address spaces for this xform. - if (isa<UndefValue>(C) || (C->isNullValue() && - cast<PointerType>(Op->getType())->getAddressSpace() == 0)) { + if (isa<UndefValue>(C) || + (C->isNullValue() && LI.getPointerAddressSpace() == 0)) { // Insert a new store to null instruction before the load to indicate that // this code is not reachable. We do this instead of inserting an // unreachable instruction directly because we cannot modify the CFG. @@ -11640,8 +11639,7 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) { if (SI.isVolatile()) return 0; // Don't hack volatile stores. // store X, null -> turns into 'unreachable' in SimplifyCFG - if (isa<ConstantPointerNull>(Ptr) && - cast<PointerType>(Ptr->getType())->getAddressSpace() == 0) { + if (isa<ConstantPointerNull>(Ptr) && SI.getPointerAddressSpace() == 0) { if (!isa<UndefValue>(Val)) { SI.setOperand(0, UndefValue::get(Val->getType())); if (Instruction *U = dyn_cast<Instruction>(Val)) diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 3c6dcadaa7..155e91ec7b 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1131,8 +1131,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) { if (PtrVal.isConstant() && !I.isVolatile()) { Value *Ptr = PtrVal.getConstant(); // TODO: Consider a target hook for valid address spaces for this xform. - if (isa<ConstantPointerNull>(Ptr) && - cast<PointerType>(Ptr->getType())->getAddressSpace() == 0) { + if (isa<ConstantPointerNull>(Ptr) && I.getPointerAddressSpace() == 0) { // load null -> null markConstant(IV, &I, Constant::getNullValue(I.getType())); return; diff --git a/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/lib/Transforms/Scalar/SimplifyCFGPass.cpp index 5de79c49cf..ca4292bcaa 100644 --- a/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -132,7 +132,7 @@ static bool MarkAliveBlocks(BasicBlock *BB, if (isa<UndefValue>(Ptr) || (isa<ConstantPointerNull>(Ptr) && - cast<PointerType>(Ptr->getType())->getAddressSpace() == 0)) { + SI->getPointerAddressSpace() == 0)) { ChangeToUnreachable(SI, Context); Changed = true; break; |