In the above CFG, the terminator of Flow2 is identified as divergent and hence Flow2 is inserted into the DivergentTermBlocks set. However, upon a query of the branch instruction br i1 %8, label %if1, label %endloop is uniform or not, uniformity analysis returns true. That is, DivergentTermBlocks does not contain Flow2.
Or to put it differently, the analysis runs until it reaches a fixed point, and the set of divergent operations keeps increasing monotonically. It does not backtrack on operations that are identified as divergent.
What you are seeing could potentially be a bug. Can you please provide the IR for this graph?
When isUniform(..) runs to check whether br i1 %8, label %if1, label %endloop is uniform or not, UA returns true if its parent basic block Flow2 is in the DivergentTermBlocks set.