[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jan 18 23:40:34 PST 2006
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.415 -> 1.416
---
Log message:
Implement casts.ll:test26: a cast from float -> double -> integer, doesn't
need the float->double part.
---
Diffs of the changes: (+11 -2)
InstructionCombining.cpp | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.415 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.416
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.415 Mon Jan 16 13:47:21 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Jan 19 01:40:22 2006
@@ -3799,8 +3799,8 @@
// isEliminableCastOfCast - Return true if it is valid to eliminate the CI
// instruction.
//
-static inline bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy,
- const Type *DstTy, TargetData *TD) {
+static bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy,
+ const Type *DstTy, TargetData *TD) {
// It is legal to eliminate the instruction if casting A->B->A if the sizes
// are identical and the bits don't get reinterpreted (for example
@@ -3856,6 +3856,15 @@
return ResultCast == FirstCast;
}
}
+
+ // If this is a cast from 'float -> double -> integer', cast from
+ // 'float -> integer' directly, as the value isn't changed by the
+ // float->double conversion.
+ if (SrcTy->isFloatingPoint() && MidTy->isFloatingPoint() &&
+ DstTy->isIntegral() &&
+ SrcTy->getPrimitiveSize() < MidTy->getPrimitiveSize())
+ return true;
+
return false;
}
More information about the llvm-commits
mailing list