[PATCH] D50433: A New Divergence Analysis for LLVM

Simon Moll via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 02:32:23 PDT 2018


simoll added a comment.

In https://reviews.llvm.org/D50433#1210654, @nhaehnle wrote:

> Also, maybe I missed it, but could you state clearly in a comment what the assumed preconditions are for correctness?


I will add comments to the class declarations of the DA and SDA - they require the CFG to be reducible.

In https://reviews.llvm.org/D50433#1210654, @nhaehnle wrote:

> And in particular, how do you propose we deal with unstructured loops? This looks like a regression to me at this point.


Irreducible loops are rare and so i was planning to add support for them in a future revision.
This implementation covers the most frequent case - reducible loops with unstructured acyclic control.
If you apply the current implementation to irreducible loops it may miss join points that are only reached by disjoint paths that wrap around the loop headers.

Workarounds
-----------

1. Explicitly check for irreducible control in the `LegacyDivergenceAnalysis` and only use `GPUDivergenceAnalysis` if the CFG is reducible. That is ignore the flag `-use-gpu-divergence-analysis` in irreducible control.
2. There is a pessimistic work around: in the SDA we could pretend that there are distinct definitions at each loop header. This should not cause regressions for the reducible loop case. There would also be some minor changes in the DA (range of live out tainting).

Proper implementation
---------------------

In the SDA, run a fixed point loop until the definitions at the loop headers stabilize (somewhat like https://reviews.llvm.org/D50433#1210817).
The DA changes would be the same as in workaround #2.

Proposed solution
-----------------

Do workaround #1 now and supplement precise irreducible loop handling in a future revision (first workaround #2 to test the DA changes, then the proper SDA implementation).
That way there are no regressions compared to the existing DA and, unlike now, results will be sound on the by far more frequent reducible CFG case.


Repository:
  rL LLVM

https://reviews.llvm.org/D50433





More information about the llvm-commits mailing list