[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp SCCP.cpp
Chris Lattner
clattner at apple.com
Mon Dec 11 21:35:49 PST 2006
> -/// 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());
You're going to have to decide on the signedness at some point.
Considering that this is used for gep indices, I'd guess they must be
signed.
> + else
> + return ConstantExpr::getPtrToInt(CB, UIntPtrTy);
>
> Value *&New = CastedPointers[V];
> if (New) return New;
>
>
> Index: llvm/lib/Transforms/Scalar/SCCP.cpp
> diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.140 llvm/lib/
> Transforms/Scalar/SCCP.cpp:1.141
> --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.140 Wed Dec 6 19:30:31 2006
> +++ llvm/lib/Transforms/Scalar/SCCP.cpp Mon Dec 11 23:04:59 2006
> @@ -589,7 +589,8 @@
> 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()));
> }
Nice bug.
-Chris
More information about the llvm-commits
mailing list