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

Pankaj Dwivedi via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 05:31:30 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);
----------------
PankajDwivedi-25 wrote:

The `DA &&` guard is needed because we return a default-constructed UniformityInfo{} (with DA = nullptr) on non-divergent targets, skipping the CycleAnalysis fetch that's the optimization targeted by this patch.

If DA shouldn't be nullable here, we'd need an alternative way to construct a lightweight UniformityInfo without requiring CycleInfo (e.g., a new constructor or a static empty instance)?

Please suggest.

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


More information about the llvm-commits mailing list