[llvm] [UniformityAnalysis] Skip CycleAnalysis on targets without branch divergence (PR #189948)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 06:27:28 PDT 2026


================
@@ -1289,29 +1289,35 @@ GenericUniformityInfo<ContextT>::getFunction() const {
 }
 
 /// Whether \p V is divergent at its definition.
+/// A default-constructed instance (no analysis computed) reports everything
+/// as uniform, which is conservatively correct for non-divergent targets.
 template <typename ContextT>
 bool GenericUniformityInfo<ContextT>::isDivergent(ConstValueRefT V) const {
-  return DA->isDivergent(V);
+  return DA && DA->isDivergent(V);
----------------
jayfoad wrote:

> I'd assume this would work by guarding the use of UniformityInfo in its availability rather than putting the availability check in UniformityInfo, that's the way every other optional dependence works (e.g. DominatorTree)

But it's a different use case. For DominatorTree, sure passes can decide not to use it (and presumably get less optimal results) if they want to. But for UA it is much simpler if passes can use it unconditionally, and having UA skip the call to CycleAnalysis in some cases is just a compile-time optimization that those passes don't need to be aware of.

https://github.com/llvm/llvm-project/pull/189948


More information about the llvm-commits mailing list