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
This commit is contained in:
Reid Spencer 2006-12-12 05:38:50 +00:00
parent f0094839f0
commit f25212a223

View File

@ -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);
}