[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jul 20 21:27:34 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.228 -> 1.229
---
Log message:
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
---
Diffs of the changes: (+5 -8)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.228 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.229
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.228 Tue Jul 20 00:21:00 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 20 23:27:24 2004
@@ -1974,14 +1974,11 @@
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...
More information about the llvm-commits
mailing list