[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
Mon Sep 16 11:22:26 PDT 2019


fhahn added a comment.

In D67612#1671530 <https://reviews.llvm.org/D67612#1671530>, @asbirlea wrote:

> Here are a couple of answers/discussion points:
>
> First of, could you please elaborate a bit more on what you're trying to check for? Is it stores before the loop, after the loop or both?


The idea here is to check stores before the loop and use the store to determine the loaded value in a specific loop iteration. We only do that if we can determine a base pointer + constant offset for a certain loop iteration.

> Normally we'd use the walker on the instruction (`MSSA->getWalker()->getClobberingMemoryAccess(&I)`) to look before the loop. Ideally we'd avoid going into the innards of MSSA in loop passes, so if a usecase not covered by the walker is needed that should be added either to a walker or to the updater.
>  It looks like a good use of MemorySSA, but the search should happen behind an API.

Right, but the walker just does a single step, which might not be the defining instructions we are looking for. Would the recommended way to implement this to implement a new walker, which just looks for a MemDef with said base pointer + offset?

> Secondly, in the new pass manager it is necessary for MSSA to be preserved by all loop passes in the same loop pipeline, because analyses are not actually invalidated until the entire loop pipeline is done. Hence it's possible to end up using an invalidated analysis and only notice this on a crash, miscompile or non-deterministic behavior. This occurred in D65060 <https://reviews.llvm.org/D65060> and I tried to add a safety net in D66376 <https://reviews.llvm.org/D66376> to prevent this from happening again (LPM2 will not use MSSA even if LoopUnroll is taught to preserve it,  until all other passes in LPM2 all preserve it).
> 
> As far as preserving MemorySSA in LoopUnroll, this is a complex task. I had started work in this, but I did not complete it because unrolling does a lot of cloning/copying, and adding instructions "out of nowhere" to MSSA can lead to complex updates. It may be worth evaluating if updating MSSA is worth it for the unroll pass, or if it's faster to rebuild it from scratch. I did not get a chance to make this evaluation.

Right, I expect this to be a fair bit of work, but I'd be happy to look into it as pre-requisite for this patch.


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