Results of convergent operations are implicitly affected by the enclosing control flows and should not be hoisted out of arbitrary loops.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Results of convergent operations are implicitly affected by the enclosing control flows and should not be hoisted out of arbitrary loops.
I thought it was OK to hoist them out of loops, but not to sink them into loops? The langref says they "should not be made control-dependent on additional values".
In practice, convergent attribute has been used on operations that involve inter-thread communication which results are implicitly affected by the enclosing control flows. This was pointed out in the proposal in https://reviews.llvm.org/D85603. The definition in the current langref doesn't reflect how the attribute is used.
D85603 requires changes to IR to model the dependency of convergent operations on their enclosing control flows.
The change in this review solves a different problem, it is to prevent hoisting with the existing IR.
This is allowed by the current definition. See D85603
I was gong to say that @xiaoqing_wu's patch looks good to me, but I didn't think this was allowed by the current definition, but you're right it looks like it is.
Now, in practice is this something that works for you guys?
I would rather that we fix that asap than pinning that on the new convergence revamp, but if the current definition is okay for some users, I guess we'll have to explore a more target specific way to describe what is and what is not okay to hoist.
What do you think?
Cheers,
-Quentin
This moves in the more conservative direction more in line with the new definition. It's good for some convergent cases, but not all. For the machine level, I don't think we have an answer for the equivalent of the convergence operands yet.
llvm/lib/Transforms/Scalar/LICM.cpp | ||
---|---|---|
1167 | isConvergent instead of directly checking the attribute |
I think it could at least do with a comment explaining that LICM is being more conservative than the documented meaning of "convergent".
Added a comment on why convergent instructions should not be hoisted or sunk in LICM and machineLICM.
isConvergent instead of directly checking the attribute