[PATCH] D30350: [LSR] Add a cap for reassociation of AllFixupsOutsideLoop type LSRUse to protect compile time

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 13:41:12 PST 2017


wmi created this revision.
Herald added a subscriber: mzolotukhin.

In PR32043, we saw a testcase containing a AllFixupsOutsideLoop type LSRUse with huge SCEVAddExpr. LSRInstance::GenerateReassociations generates lots of new formula for the LSRUse because of the huge AddExpr, and causes compilation to hang.

Since AllFixupsOutsideLoop type LSRUses are outside of current loop, reassociation for them should have much less impact compared with that for normal LSRUses. The fix is to add a cap in reassociation if the LSRUse is of AllFixupsOutsideLoop type. I admit this is a workround. AllFixupsOutsideLoop LSRUse needs to be handled in a better way to reduce compile time and improve LSR results.

No test because I am not sure the potential hanging test from PR32043 is proper to be added.


Repository:
  rL LLVM

https://reviews.llvm.org/D30350

Files:
  lib/Transforms/Scalar/LoopStrengthReduce.cpp


Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3423,6 +3423,12 @@
   if (AddOps.size() == 1)
     return;
 
+  // For AllFixupsOutsideLoop uses, their reassociations have less impact than
+  // normal uses since they are outside of current loop.
+  // Arbitrarily choose a cap size of AddOps to protect compile time.
+  if (AddOps.size() >= 5 && LU.AllFixupsOutsideLoop)
+    return;
+
   for (SmallVectorImpl<const SCEV *>::const_iterator J = AddOps.begin(),
                                                      JE = AddOps.end();
        J != JE; ++J) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30350.89714.patch
Type: text/x-patch
Size: 732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170224/b4550cbb/attachment.bin>


More information about the llvm-commits mailing list