[llvm-commits] [llvm] r89121 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp

Bob Wilson bob.wilson at apple.com
Tue Nov 17 10:30:09 PST 2009


Author: bwilson
Date: Tue Nov 17 12:30:09 2009
New Revision: 89121

URL: http://llvm.org/viewvc/llvm-project?rev=89121&view=rev
Log:
Remove a special case for tail merging that seems to be both broken and
unnecessary.  It is broken because the "isIdenticalTo" check should be
negated.  If that is fixed, this code causes the CodeGen/X86/tail-opts.ll
test to fail, in the dont_merge_oddly function.  And, I confirmed that the
regression is real -- the generated code is worse.  As far as I can tell,
that tail-opts.ll test is checking for what this code is supposed to handle
and we're doing the right thing anyway.

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

Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=89121&r1=89120&r2=89121&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Tue Nov 17 12:30:09 2009
@@ -670,39 +670,6 @@
   // this many instructions in common.
   unsigned minCommonTailLength = TailMergeSize;
 
-  // If there's a successor block, there are some cases which don't require
-  // new branching and as such are very likely to be profitable.
-  if (SuccBB) {
-    if (SuccBB->pred_size() == MergePotentials.size() &&
-        !MergePotentials[0].getBlock()->empty()) {
-      // If all the predecessors have at least one tail instruction in common,
-      // merging is very likely to be a win since it won't require an increase
-      // in static branches, and it will decrease the static instruction count.
-      bool AllPredsMatch = true;
-      MachineBasicBlock::iterator FirstNonTerm;
-      unsigned MinNumTerms = CountTerminators(MergePotentials[0].getBlock(),
-                                              FirstNonTerm);
-      if (FirstNonTerm != MergePotentials[0].getBlock()->end()) {
-        for (unsigned i = 1, e = MergePotentials.size(); i != e; ++i) {
-          MachineBasicBlock::iterator OtherFirstNonTerm;
-          unsigned NumTerms = CountTerminators(MergePotentials[0].getBlock(),
-                                               OtherFirstNonTerm);
-          if (NumTerms < MinNumTerms)
-            MinNumTerms = NumTerms;
-          if (OtherFirstNonTerm == MergePotentials[i].getBlock()->end() ||
-              OtherFirstNonTerm->isIdenticalTo(FirstNonTerm)) {
-            AllPredsMatch = false;
-            break;
-          }
-        }
-
-        // If they all have an instruction in common, do any amount of merging.
-        if (AllPredsMatch)
-          minCommonTailLength = MinNumTerms + 1;
-      }
-    }
-  }
-
   DEBUG(errs() << "\nTryTailMergeBlocks: ";
         for (unsigned i = 0, e = MergePotentials.size(); i != e; ++i)
           errs() << "BB#" << MergePotentials[i].getBlock()->getNumber()





More information about the llvm-commits mailing list