diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 5 | 
1 files changed, 3 insertions, 2 deletions
| diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 2aa0524dfd0..710b738cd24 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -1531,9 +1531,10 @@ Constant *ConstantExpr::getFPCast(Constant *C, const Type *Ty) {           "Invalid cast");    unsigned SrcBits = C->getType()->getPrimitiveSizeInBits();    unsigned DstBits = Ty->getPrimitiveSizeInBits(); +  if (SrcBits == DstBits) +    return C; // Avoid a useless cast    Instruction::CastOps opcode = -    (SrcBits == DstBits ? Instruction::BitCast : -     (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt)); +     (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt);    return getCast(opcode, C, Ty);  } | 

