Don't assume that the operand of an inttoptr is an pointer-sized integer.
authorDan Gohman <gohman@apple.com>
Fri, 21 Aug 2009 18:27:26 +0000 (18:27 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 21 Aug 2009 18:27:26 +0000 (18:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79651 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp

index 19ea6033752ef2af89c1666338c5c2db271d79d7..5dcb021acf6f911659671d21a479840759eef7ff 100644 (file)
@@ -138,8 +138,10 @@ static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps,
     // otherwise we can't.
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Ptr))
       if (CE->getOpcode() == Instruction::IntToPtr)
-        if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0)))
+        if (ConstantInt *Base = dyn_cast<ConstantInt>(CE->getOperand(0))) {
           BasePtr = Base->getValue();
+          BasePtr.zextOrTrunc(BitWidth);
+        }
     
     if (BasePtr == 0)
       BaseIsInt = false;