[llvm-dev] loop transforms and function analyses; especially divergence analysis

Sameer Sahasrabuddhe via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 16 00:09:43 PST 2021


Here's an attempt at fixing the original problem, which is that SimpleLoopUnswitch needs access to divergence analysis ... non-trivial branches should not be unswitched if they are divergent because that is harmful to performance.

https://reviews.llvm.org/D96754

>From the commit description:

"Loop unswitching on divergent conditions is harmful for
performance. The LoopUnswitch pass depends on LegacyDivergenceAnalysis
to avoid this, but the state of divergence analysis may be
stale (neither preserved nor invalidated) due to previous loop passes.

"The new pass manager provides SimpleLoopUnswitch which currently does
not skip divergent branches. Loop passes can request function analysis
results from an "outer proxy" analysis manager, but only if such
results are never invalidated. This change introduces another method
to request an analysis from the outer proxy even if it is stale. This
is sufficient for the current use-case, where it is not necessary to
update the divergence analysis after every loop pass, and the existing
stale result is still safely useable. The effect is equivalent to the
use of divergence analysis by LoopUnswitch in the legacy pass manager."

This arrangement is clearly different from LoopStandardAnalysisResults, which must always be updated by every loop pass. This change introduces a new class of analysis results that does not have to be passed as an argument to every loop pass. It is sufficient that they are made available by the loop pass manager, but with no guarantees about the state of the result. They are known to be available and valid when the loop passes start, and remain available via the outer proxy, although not necessarily valid. 

Sameer. 

---- On Fri, 12 Feb 2021 23:13:35 +0530 Sameer Sahasrabuddhe <sameer at sbuddhe.net> wrote ----

 > Here's an attempt to add divergence analysis to the new pass manager as the first step:
 > 
 > https://reviews.llvm.org/D96615
 > 
 > This only introduces the analysis, and does not try to use it with other passes like SimpleLoopUnswitch. That comes next.
 > 
 > Sameer.
 > 
 > 



More information about the llvm-dev mailing list