[llvm] [UniformityAnalysis] Track uniform values for conservative divergence queries (PR #180509)
Pankaj Dwivedi via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 07:49:20 PST 2026
================
@@ -392,7 +402,15 @@ template <typename ContextT> class GenericUniformityAnalysisImpl {
};
/// \brief Whether \p Val is divergent at its definition.
- bool isDivergent(ConstValueRefT V) const { return DivergentValues.count(V); }
+ /// When UniformValues is populated (after finalization), values not in
+ /// either set (e.g. newly created) are conservatively treated as divergent.
+ bool isDivergent(ConstValueRefT V) const {
+ if (ContextT::isNeverDivergent(V))
+ return false;
+ if (UniformValues.empty())
----------------
PankajDwivedi-25 wrote:
> If I follow everything, we're using `UniformValues.empty()` to differentiate the moment before/after `finalizeUniformValues` was called. Right?
Yes.
> I think we could then have two versions of this method:
>
> ```c++
> public:
> bool isDivergent(ConstValueRefT V) const {
> if (ContextT::isNeverDivergent(V))
> return false;
> return !UniformValues.contains(V);
> }
>
> protected:
> // only used during the construction of the analysis (names are difficult)
> bool isDivergentUnderConstruction(ConstValueRefT V) const {
> if (ContextT::isNeverDivergent(V))
> return false;
> return DivergentValues.contains(V);
> }
> ```
>
> During the construction of the analysis we only call (2). The users of the analysis only call (1).
>
> After `finalizeUniformValues`, `DivergentValues` is not used anymore, so you can clear it
Yes, that would be a nice separation of these two uses of a single API.
It will require massive cleanup.
https://github.com/llvm/llvm-project/pull/180509
More information about the llvm-commits
mailing list