[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp

Reid Spencer reid at x10sys.com
Mon Dec 11 21:39:05 PST 2006



Changes in directory llvm/lib/VMCore:

Constants.cpp updated: 1.185 -> 1.186
---
Log message:

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


---
Diffs of the changes:  (+3 -2)

 Constants.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.185 llvm/lib/VMCore/Constants.cpp:1.186
--- llvm/lib/VMCore/Constants.cpp:1.185	Mon Dec 11 18:51:07 2006
+++ llvm/lib/VMCore/Constants.cpp	Mon Dec 11 23:38:50 2006
@@ -1531,9 +1531,10 @@
          "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);
 }
 






More information about the llvm-commits mailing list