diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 66b595fd7f7..c132aaef927 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -200,12 +200,17 @@ FunctionPass *llvm::createLoopStrengthReducePass(const TargetLowering *TLI) { return new LoopStrengthReduce(TLI); } -/// getCastedVersionOf - Return the specified value casted to uintptr_t. +/// getCastedVersionOf - Return the specified value casted to uintptr_t. This +/// assumes that the Value* V is of integer or pointer type only. /// Value *LoopStrengthReduce::getCastedVersionOf(Value *V) { if (V->getType() == UIntPtrTy) return V; if (Constant *CB = dyn_cast<Constant>(V)) - return ConstantExpr::getCast(CB, UIntPtrTy); + if (CB->getType()->isInteger()) + return ConstantExpr::getIntegerCast(CB, UIntPtrTy, + CB->getType()->isSigned()); + else + return ConstantExpr::getPtrToInt(CB, UIntPtrTy); Value *&New = CastedPointers[V]; if (New) return New; diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index 5d928c145df..4f0607ef294 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -589,7 +589,8 @@ void SCCPSolver::visitCastInst(CastInst &I) { if (VState.isOverdefined()) // Inherit overdefinedness of operand markOverdefined(&I); else if (VState.isConstant()) // Propagate constant value - markConstant(&I, ConstantExpr::getCast(VState.getConstant(), I.getType())); + markConstant(&I, ConstantExpr::getCast(I.getOpcode(), + VState.getConstant(), I.getType())); } void SCCPSolver::visitSelectInst(SelectInst &I) { |

