From e8a7e593e6caf0d9ecaac24033bc886081949181 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 21 Jul 2004 04:27:24 +0000 Subject: [PATCH] Remove special casing of pointers and treat them generically as integers of the appopriate size. This gives us the ability to eliminate int -> ptr -> int git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15063 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 376222ffe27..4634b6d9c42 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1974,14 +1974,11 @@ static inline bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy, if (SrcTy == DstTy && SrcTy->isLosslesslyConvertibleTo(MidTy)) return true; - // If the source and destination types are pointer types, and the intermediate - // is an integer type bigger than a pointer, eliminate the casts. - if (isa(SrcTy) && isa(DstTy)) { - if (isa(MidTy)) return true; - - if (MidTy->isInteger() && MidTy->getPrimitiveSize() >= TD->getPointerSize()) - return true; - } + // If we are casting between pointer and integer types, treat pointers as + // integers of the appropriate size for the code below. + if (isa(SrcTy)) SrcTy = TD->getIntPtrType(); + if (isa(MidTy)) MidTy = TD->getIntPtrType(); + if (isa(DstTy)) DstTy = TD->getIntPtrType(); // Allow free casting and conversion of sizes as long as the sign doesn't // change...