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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69307 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 972e4e9..a3a6ff3 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -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();