[PATCH] D30552: Fix regressions cased by D29862

Evgeny Stupachenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 16:57:41 PST 2017


evstupac added a comment.

> Could you explain what was the problem and how this patch addresses it?

Sure, here is the case:

Use1 (Address):
{a} + {0,+,1} register num expectation 1 + 1/2
{a,+,1} register num expectation 1
Use2 (Address):
{b} + {0,+,1}
{b,+,1}
Use3 (ICmpZero):
-1024 + {0,+,1}

That way new method will select {a,+1} {b,+,1} and -1024 + {0,+,1} which is not optimal in terms of AddRecExprs (still optimal in terms of RegNum)

In Matrix test there are 32 Address uses like above. The expectation of {a} + {0,+,1} becomes very close 1, but still grater than 1.
The solution is simple - delete formulas in ICmpZero before Address. That way the optimal solution is selected (as {0,+,1} becomes unique).



================
Comment at: lib/Transforms/Scalar/LoopStrengthReduce.cpp:4446
     }
-    LU.RecomputeRegs(LUIdx, RegUses);
     assert(LU.Formulae.size() == 1 && "Should be exactly 1 min regs formula");
     Formula &F = LU.Formulae[0];
----------------
qcolombet wrote:
> Why don't we have to update Regs anymore?
This is a kind of unrelated change (as it is redundant initially). We leave only 1 formula in each LSRUse, therfore we already select a solution (or no solution). That way we don't need to RecomputeRegs any more.
If we keep RecomputeRegs here we'll need to sort indexes instead of LSRUses as RecomputeRegs use LSRUse indexes.


Repository:
  rL LLVM

https://reviews.llvm.org/D30552





More information about the llvm-commits mailing list