Catching up on uniformity analysis

Hello,

I have been working on replacing the LegacyDivergenceAnalysis in AMDGPUUnifyDivergentExitNodes with the new uniformity analysis. Two of the tests reported a failure in SIAnnotateControlFlow because some basic blocks were reported as not uniformly reachable with the use of uniformity analysis. The tests are:

  • LLVM :: CodeGen/AMDGPU/multi-divergent-exit-region.ll
  • LLVM :: CodeGen/AMDGPU/si-unify-exit-return-unreachable.ll

Here’s the CFG of a failing kernel:

exit0 is reported as a not uniformly reachable basic block by LegacyDA whereas Uniformity Analysis reports it as uniformly reachable.

Thank you!

My initial guess would be that UniformityAnalysis doesn’t handle switch instructions

If UA finds uniformity where LegacyDA does not, that’s a good thing, right? The reasonable way forward will be dump both analyses and compare which values are marked divergent/uniform in each.

1 Like

I think you’re right. It appears to be a bug in SIAnnotateControlFlow. AMDGPUUnifyDivergentExitNodes transforms the above CFG into the following:

SIAnnotateControlFlow fails to annotate this CFG with exit1 and NodeBlock still living in the Stack.

Wild guess, but could it be that the test is simply too sensitive about the names of the blocks?

I doubt it, I think control flow is not correctly closed when visiting LeafBlock4 and NodeBlock6.