From c1c2ba7a724fbb93b386eceb04ccce4dba2c9830 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 16 Apr 2009 19:25:55 +0000 Subject: 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. llvm-svn: 69307 --- llvm/lib/Analysis/ScalarEvolution.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp') diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 972e4e984c6..a3a6ff33332 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -225,8 +225,6 @@ SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty) assert((Op->getType()->isInteger() || isa(Op->getType())) && (Ty->isInteger() || isa(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 @@ SCEVHandle ScalarEvolution::getTruncateExpr(const SCEVHandle &Op, const Type *Ty 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(Op)) { const Type *IntTy = Ty; if (isa(IntTy)) IntTy = getTargetData().getIntPtrType(); -- cgit v1.2.3