[llvm-commits] [llvm] r69307 - in /llvm/trunk/lib/Analysis: ScalarEvolution.cpp ScalarEvolutionExpander.cpp
Dan Gohman
gohman at apple.com
Thu Apr 16 12:25:55 PDT 2009
Author: djg
Date: Thu Apr 16 14:25:55 2009
New Revision: 69307
URL: http://llvm.org/viewvc/llvm-project?rev=69307&view=rev
Log:
Fix a bug with inttoptr/ptrtoint casts where the pointer has a different
size from the integer, requiring zero extension or truncation. Don't
create ZExtInsts with pointer types. This fixes a regression in
consumer-jpeg.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=69307&r1=69306&r2=69307&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Apr 16 14:25:55 2009
@@ -225,8 +225,6 @@
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() {
@@ -674,7 +672,12 @@
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();
Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=69307&r1=69306&r2=69307&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Thu Apr 16 14:25:55 2009
@@ -281,17 +281,21 @@
}
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) {
More information about the llvm-commits
mailing list