assert((Op->getType()->isInteger() || isa<PointerType>(Op->getType())) &&
(Ty->isInteger() || isa<PointerType>(Ty)) &&
"Cannot zero extend non-integer value!");
- assert(Op->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()
- && "This is not an extending conversion!");
}
SCEVZeroExtendExpr::~SCEVZeroExtendExpr() {
return Result;
}
-SCEVHandle ScalarEvolution::getZeroExtendExpr(const SCEVHandle &Op, const Type *Ty) {
+SCEVHandle ScalarEvolution::getZeroExtendExpr(const SCEVHandle &Op,
+ const Type *Ty) {
+ assert(getTargetData().getTypeSizeInBits(Op->getType()) <
+ getTargetData().getTypeSizeInBits(Ty) &&
+ "This is not an extending conversion!");
+
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Op)) {
const Type *IntTy = Ty;
if (isa<PointerType>(IntTy)) IntTy = getTargetData().getIntPtrType();
}
Value *SCEVExpander::visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
+ const Type *Ty = S->getType();
+ if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
Value *V = expand(S->getOperand());
if (isa<PointerType>(V->getType()))
V = InsertCastOfTo(Instruction::PtrToInt, V, TD.getIntPtrType());
- return CastInst::CreateZExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
+ return CastInst::CreateZExtOrBitCast(V, Ty, "tmp.", InsertPt);
}
Value *SCEVExpander::visitSignExtendExpr(SCEVSignExtendExpr *S) {
+ const Type *Ty = S->getType();
+ if (isa<PointerType>(Ty)) Ty = TD.getIntPtrType();
Value *V = expand(S->getOperand());
if (isa<PointerType>(V->getType()))
V = InsertCastOfTo(Instruction::PtrToInt, V, TD.getIntPtrType());
- return CastInst::CreateSExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
+ return CastInst::CreateSExtOrBitCast(V, Ty, "tmp.", InsertPt);
}
Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) {