Update CMakeLists.txt
[oota-llvm.git] / lib / Analysis / ConstantFolding.cpp
index d3d0eb61ec15c0146ff6cc544d65fff6ebdcc20a..9f94ee383374abf100ae8bd1e714162771e99aac 100644 (file)
@@ -368,10 +368,12 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
       if (TD && CE->getOpcode() == Instruction::IntToPtr) {
         Constant *Input = CE->getOperand(0);
         unsigned InWidth = Input->getType()->getPrimitiveSizeInBits();
-        Constant *Mask = 
-          ConstantInt::get(APInt::getLowBitsSet(InWidth,
-                                                TD->getPointerSizeInBits()));
-        Input = ConstantExpr::getAnd(Input, Mask);
+        if (TD->getPointerSizeInBits() < InWidth) {
+          Constant *Mask = 
+            ConstantInt::get(APInt::getLowBitsSet(InWidth,
+                                                  TD->getPointerSizeInBits()));
+          Input = ConstantExpr::getAnd(Input, Mask);
+        }
         // Do a zext or trunc to get to the dest size.
         return ConstantExpr::getIntegerCast(Input, DestTy, false);
       }