[PATCH] D67612: [UnrolledInstAnalyzer] Use MSSA to find stored values outside of loop.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 14:00:06 PDT 2019


fhahn added a comment.

In D67612#1681623 <https://reviews.llvm.org/D67612#1681623>, @efriedma wrote:

> I think I see the gap in communication here.
>
> If you ask MSSA for the closest definition for a load inside a loop, it will return the closest store which might alias the load at any iteration.  This is what you want if you want to, for example, eliminate a load using a stored value.
>
> What we really want here, though, is not MSSA for the load, as it exists in the loop.  Instead the question is, what would MSSA return after the loop is unrolled?  (It might not return the same def: alias analysis has more information after unrolling.)  We could speculatively unroll the loop and recompute MSSA, but that would be really expensive.  Instead, the code here is walking through the defs to try to find the def that will be relevant after unrolling.


Thanks for clarifying Eli! @asbirlea, does this make more sense now?

For a bit more context: UnrolledInstAnalyzer simulates unrolling the loop and for each iteration it tries to estimate what can be simplified in that iteration. So when it analyzes the first iteration, it knows what the concrete value of the induction variable will be. If we can simplify an address computation to a base address + offset using that information, we look at clobbering stores outside the loop of the original load, and see if we can find a store that stores exactly to the same location. Note that memorySSA does not have  this additional information and the load in the loop will be clobbered by any store that involves an address covered by the loop.

The underlying motivation to do that is that such store/load pairs can be eliminated after unrolling and should not count towards the size of the unrolled loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67612





More information about the llvm-commits mailing list