diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-19 07:40:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-19 07:40:22 +0000 |
commit | bc528efa76e8d0f225630e4677c8e74d17f23fc5 (patch) | |
tree | aaed6d3b49eade2d2658d696ce4c0b4904a22b99 /lib/Transforms | |
parent | 6b8800d6a6d3864a76ff9880e6c7f0d83d24ffc7 (diff) |
Implement casts.ll:test26: a cast from float -> double -> integer, doesn't
need the float->double part.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25452 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 2fcf919484..f440e475e0 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -3799,8 +3799,8 @@ static CastType getCastType(const Type *Src, const Type *Dest) { // 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 @@ static inline bool isEliminableCastOfCast(const Type *SrcTy, const Type *MidTy, 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; } |