diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-12 05:38:50 +0000 | 
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-12 05:38:50 +0000 | 
| commit | ca104e80eed9daebabc09c9f79b9796a4d0d857c (patch) | |
| tree | 76689d639ed8590dba30a87fea773acb962cce4d | |
| parent | 2f96e7d24136be4619e8268348a215103c29fbbc (diff) | |
| download | bcm5719-llvm-ca104e80eed9daebabc09c9f79b9796a4d0d857c.tar.gz bcm5719-llvm-ca104e80eed9daebabc09c9f79b9796a4d0d857c.zip | |
Don't create usless casts for same-bith-width floating point casts.
llvm-svn: 32475
| -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);  } | 

