[PATCH] D69009: [IndVars] Eliminate loop exits with equivalent exit counts

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 19 10:06:20 PDT 2019


reames marked an inline comment as done.
reames added inline comments.


================
Comment at: lib/Transforms/Scalar/IndVarSimplify.cpp:2796
+      continue;
+    }
   }
----------------
nikic wrote:
> Now that we're traversing the exits in dominating order, I think we should consider a slightly different overall approach:
> 
> Instead of computing `umin({ exit counts })` upfront and then checking for `umin({ exit counts }) < this exit count`, we can instead build this up incrementally, i.e. take the umin between the current max exit count and the exit count of the currently considered exit at each iteration. This will allow us to check for `umin({ already seen exit counts }) <= this exit count` (note the `<=`!) instead.
> 
> This should implicitly handle the case of exact equalities, but may also be more powerful in general because we're checking for a weaker predicate.
The suggested approach doesn't handle one of the most common cases.  If the latch exit is in fact the minimum exit, we want to be able to discharge earlier exits.  (i.e. the difference between the dominating set and the total sets is important)

I do agree that your phrasing *might* be more powerful for eliminating exits which SCEV can prove are <= dominating checks (but not either < or ==).  However, I don't have a test case which demonstrates that difference, and until I do, I'd like to avoid further complicating the code.  (Assuming I'd need both approaches due to the gap described above.)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69009/new/

https://reviews.llvm.org/D69009





More information about the llvm-commits mailing list