summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-21 04:27:24 +0000
committerChris Lattner <sabre@nondot.org>2004-07-21 04:27:24 +0000
commit4fbad968f8f7c6a775cf827c53b6900361e03803 (patch)
treee57ff80cca19f91793288c5d3914b8868c421ce2 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parentfdcf624939f989c20cc3ce3bf2d2f0d0f8c3cabd (diff)
downloadbcm5719-llvm-4fbad968f8f7c6a775cf827c53b6900361e03803.tar.gz
bcm5719-llvm-4fbad968f8f7c6a775cf827c53b6900361e03803.zip
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 llvm-svn: 15063
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 376222ffe27..4634b6d9c42 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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<PointerType>(SrcTy) && isa<PointerType>(DstTy)) {
- if (isa<PointerType>(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<PointerType>(SrcTy)) SrcTy = TD->getIntPtrType();
+ if (isa<PointerType>(MidTy)) MidTy = TD->getIntPtrType();
+ if (isa<PointerType>(DstTy)) DstTy = TD->getIntPtrType();
// Allow free casting and conversion of sizes as long as the sign doesn't
// change...
OpenPOWER on IntegriCloud