Don't hoist things out of a large switch inside a
authorDale Johannesen <dalej@apple.com>
Tue, 20 Jul 2010 00:50:13 +0000 (00:50 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 20 Jul 2010 00:50:13 +0000 (00:50 +0000)
loop, for the reasons in the comments.  This is a
major win on 253.perlbmk on ARM Darwin.  I expect it
to be a good heuristic in general, but it's possible
some things will regress; I'll be watching.
7940152.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108792 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineLICM.cpp

index 4c054f51f3a8ac8a3c0733b9f9d4ddc509f34465..83f66ce0948736ebe296db1779a24ab8984c0c3a 100644 (file)
@@ -489,8 +489,12 @@ void MachineLICM::HoistRegion(MachineDomTreeNode *N) {
   }
 
   const std::vector<MachineDomTreeNode*> &Children = N->getChildren();
-  for (unsigned I = 0, E = Children.size(); I != E; ++I)
-    HoistRegion(Children[I]);
+  // Don't hoist things out of a large switch statement.  This often causes
+  // code to be hoisted that wasn't going to be executed, and increases
+  // register pressure in a situation where it's likely to matter.
+  if (Children.size() < 10)
+    for (unsigned I = 0, E = Children.size(); I != E; ++I)
+      HoistRegion(Children[I]);
 }
 
 /// IsLICMCandidate - Returns true if the instruction may be a suitable