Optionally rerun dedicated-register filtering after applying
authorDan Gohman <gohman@apple.com>
Sun, 29 Aug 2010 16:39:22 +0000 (16:39 +0000)
committerDan Gohman <gohman@apple.com>
Sun, 29 Aug 2010 16:39:22 +0000 (16:39 +0000)
other filtering techniques, as those may allow it to filter
out more obviously unprofitable candidates.

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

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 8a688063998de51320127cfa6057a5f0d5c05274..4fe93b9d415c3ff7332a931cf08c95b3becfb48e 100644 (file)
@@ -1391,6 +1391,7 @@ public:
   size_t EstimateSearchSpaceComplexity() const;
   void NarrowSearchSpaceByDetectingSupersets();
   void NarrowSearchSpaceByCollapsingUnrolledCode();
+  void NarrowSearchSpaceByRefilteringUndesirableDedicatedRegisters();
   void NarrowSearchSpaceByPickingWinnerRegs();
   void NarrowSearchSpaceUsingHeuristics();
 
@@ -3104,6 +3105,24 @@ void LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode() {
   }
 }
 
+/// NarrowSearchSpaceByRefilteringUndesirableDedicatedRegisters - Call 
+/// FilterOutUndesirableDedicatedRegisters again, if necessary, now that
+/// we've done more filtering, as it may be able to find more formulae to
+/// eliminate.
+void LSRInstance::NarrowSearchSpaceByRefilteringUndesirableDedicatedRegisters(){
+  if (EstimateSearchSpaceComplexity() >= ComplexityLimit) {
+    DEBUG(dbgs() << "The search space is too complex.\n");
+
+    DEBUG(dbgs() << "Narrowing the search space by re-filtering out "
+                    "undesirable dedicated registers.\n");
+
+    FilterOutUndesirableDedicatedRegisters();
+
+    DEBUG(dbgs() << "After pre-selection:\n";
+          print_uses(dbgs()));
+  }
+}
+
 /// NarrowSearchSpaceByPickingWinnerRegs - Pick a register which seems likely
 /// to be profitable, and then in any use which has any reference to that
 /// register, delete all formulae which do not reference that register.
@@ -3176,6 +3195,7 @@ void LSRInstance::NarrowSearchSpaceByPickingWinnerRegs() {
 void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
   NarrowSearchSpaceByDetectingSupersets();
   NarrowSearchSpaceByCollapsingUnrolledCode();
+  NarrowSearchSpaceByRefilteringUndesirableDedicatedRegisters();
   NarrowSearchSpaceByPickingWinnerRegs();
 }