[all-commits] [llvm/llvm-project] 8cbcd2: [IndVars] Eliminate loop exits with equivalent exi...

Philip Reames via All-commits all-commits at lists.llvm.org
Sun Oct 20 16:36:49 PDT 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 8cbcd2f484a2bc6720d9fd66b71aeaf50a49bc70
      https://github.com/llvm/llvm-project/commit/8cbcd2f484a2bc6720d9fd66b71aeaf50a49bc70
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2019-10-20 (Sun, 20 Oct 2019)

  Changed paths:
    M llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
    M llvm/test/Transforms/IndVarSimplify/eliminate-exit.ll
    M llvm/test/Transforms/IndVarSimplify/loop-predication.ll
    M llvm/test/Transforms/IndVarSimplify/pr38674.ll

  Log Message:
  -----------
  [IndVars] Eliminate loop exits with equivalent exit counts

We can end up with two loop exits whose exit counts are equivalent, but whose textual representation is different and non-obvious. For the sub-case where we have a series of exits which dominate one another (common), eliminate any exits which would iterate *after* a previous exit on the exiting iteration.

As noted in the TODO being removed, I'd always thought this was a good idea, but I've now seen this in a real workload as well.

Interestingly, in review, Nikita pointed out there's let another oppurtunity to leverage SCEV's reasoning.  If we kept track of the min of dominanting exits so far, we could discharge exits with EC >= MDE.  This is less powerful than the existing transform (since later exits aren't considered), but potentially more powerful for any case where SCEV can prove a >= b, but neither a == b or a > b.  I don't have an example to illustrate that oppurtunity, but won't be suprised if we find one and return to handle that case as well.  

Differential Revision: https://reviews.llvm.org/D69009

llvm-svn: 375379




More information about the All-commits mailing list