summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-12 05:38:50 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-12 05:38:50 +0000
commitca104e80eed9daebabc09c9f79b9796a4d0d857c (patch)
tree76689d639ed8590dba30a87fea773acb962cce4d /llvm/lib
parent2f96e7d24136be4619e8268348a215103c29fbbc (diff)
downloadbcm5719-llvm-ca104e80eed9daebabc09c9f79b9796a4d0d857c.tar.gz
bcm5719-llvm-ca104e80eed9daebabc09c9f79b9796a4d0d857c.zip
Don't create usless casts for same-bith-width floating point casts.
llvm-svn: 32475
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp5
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);
}
OpenPOWER on IntegriCloud