[llvm-commits] [llvm] r90147 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp

Bob Wilson bob.wilson at apple.com
Mon Nov 30 10:56:45 PST 2009


Author: bwilson
Date: Mon Nov 30 12:56:45 2009
New Revision: 90147

URL: http://llvm.org/viewvc/llvm-project?rev=90147&view=rev
Log:
Reprioritize tests for tail duplication to be aggressive about indirect
branches even when optimizing for code size.  Unless we find evidence to the
contrary in the future, the special treatment for indirect branches does not
have a significant effect on code size, and performance still matters with -Os.

Modified:
    llvm/trunk/lib/CodeGen/TailDuplication.cpp

Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90147&r1=90146&r2=90147&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Mon Nov 30 12:56:45 2009
@@ -116,14 +116,14 @@
   // duplicate only one, because one branch instruction can be eliminated to
   // compensate for the duplication.
   unsigned MaxDuplicateCount;
-  if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
-    MaxDuplicateCount = 1;
-  else if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch())
+  if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch())
     // If the target has hardware branch prediction that can handle indirect
     // branches, duplicating them can often make them predictable when there
     // are common paths through the code.  The limit needs to be high enough
     // to allow undoing the effects of tail merging.
     MaxDuplicateCount = 20;
+  else if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize))
+    MaxDuplicateCount = 1;
   else
     MaxDuplicateCount = TailDuplicateSize;
 





More information about the llvm-commits mailing list