1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Don't create usless casts for same-bith-width floating point casts.

llvm-svn: 32475
This commit is contained in:
Reid Spencer 2006-12-12 05:38:50 +00:00
parent ddb1fa5291
commit e9161a2f5e

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