[llvm-commits] [llvm] r167685 - /llvm/trunk/lib/Target/TargetTransformImpl.cpp

Nadav Rotem nrotem at apple.com
Sat Nov 10 21:34:45 PST 2012


Author: nadav
Date: Sat Nov 10 23:34:45 2012
New Revision: 167685

URL: http://llvm.org/viewvc/llvm-project?rev=167685&view=rev
Log:
Use the isTruncFree and isZExtFree API to figure out of these operations are free. Thanks Andy!

Modified:
    llvm/trunk/lib/Target/TargetTransformImpl.cpp

Modified: llvm/trunk/lib/Target/TargetTransformImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetTransformImpl.cpp?rev=167685&r1=167684&r2=167685&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetTransformImpl.cpp (original)
+++ llvm/trunk/lib/Target/TargetTransformImpl.cpp Sat Nov 10 23:34:45 2012
@@ -214,8 +214,16 @@
   // Handle scalar conversions.
   if (!Src->isVectorTy() && !Dst->isVectorTy()) {
 
-    // Scalar bitcasts and truncs are usually free.
-    if (Opcode == Instruction::BitCast || Opcode == Instruction::Trunc)
+    // Scalar bitcasts are usually free.
+    if (Opcode == Instruction::BitCast)
+      return 0;
+
+    if (Opcode == Instruction::Trunc &&
+        TLI->isTruncateFree(SrcLT.second, DstLT.second))
+      return 0;
+
+    if (Opcode == Instruction::ZExt &&
+        TLI->isZExtFree(SrcLT.second, DstLT.second))
       return 0;
 
     // Just check the op cost. If the operation is legal then assume it costs 1.





More information about the llvm-commits mailing list