From: Reid Spencer Date: Tue, 12 Dec 2006 05:38:50 +0000 (+0000) Subject: Don't create usless casts for same-bith-width floating point casts. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f25212a223b649bf602d3a0489254139cd2c07e4;p=oota-llvm.git Don't create usless casts for same-bith-width floating point casts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32475 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 2aa0524dfd0..710b738cd24 100644 --- a/lib/VMCore/Constants.cpp +++ b/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); }