diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index f00be24aad0df0224369f86c4e594bdce20e64ac..cc7d8b9263aef6b54c4a8b148a28e36d6a683565 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -377,9 +377,9 @@ static bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy, // If we are casting between pointer and integer types, treat pointers as // integers of the appropriate size for the code below. - if (isa<PointerType>(SrcTy)) SrcTy = TD->getIntPtrType(); - if (isa<PointerType>(MidTy)) MidTy = TD->getIntPtrType(); - if (isa<PointerType>(DstTy)) DstTy = TD->getIntPtrType(); + if (isa<PointerType>(SrcTy)) SrcTy = TD->getIntPtrType()->getSignedVersion(); + if (isa<PointerType>(MidTy)) MidTy = TD->getIntPtrType()->getSignedVersion(); + if (isa<PointerType>(DstTy)) DstTy = TD->getIntPtrType()->getSignedVersion(); // Allow free casting and conversion of sizes as long as the sign doesn't // change...