As the test case demonstrates, it is possible for a block to be identified as a
join point while not being the header of a reducible cycle. To address this,
when searching for the outermost cycle made divergent by branch outside it, we
first check for an irreducible outermost cycle before checking if the parent is
reducible.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/include/llvm/ADT/GenericUniformityImpl.h | ||
---|---|---|
950 | We shouldn't remove the assert. Instead, this whole "if block" should be moved after the while loop below. The reasoning is like this: When divergent paths enter an irreducible cycle, we assume that everything inside the cycle is divergent. But the way ModifiedPO works, every block inside the cycle gets marked as a join block. This is okay, because the exits get labelled as themselves which allows the traversal to find actual joins outside (or beyond) the cycle. So when we want to check a join block inside a cycle C relative to a divergent branch outside of C, we should first check if there is an irreducible parent of C that does not contain the branch. If there is such a parent, then whether C is reducible is not relevant. If there is no irreducible parent, then we can check if C is reducible. Returning early like the current code, by just checking the parent cycle looks like a bug because it fails to return the irreducible parent as the "cycle made divergent". But other join blocks in the irreducible parent will cause it to be eventually reported, so it's okay. |
Can you please reword the change description? Rather than talking about the code in terms of if/while, it's more helpful to talk about what is happening. For example, "we should first check for an irreducible outermost cycle before checking if the parent is reducible".
Okay, I've updated the description, @sameerds could you please submit this on my behalf?
@AlexM FYI: submitted a different fix in the same location: 4d081560cd3b6ac114aee15f50480dd978b55a44
We shouldn't remove the assert. Instead, this whole "if block" should be moved after the while loop below.
The reasoning is like this: When divergent paths enter an irreducible cycle, we assume that everything inside the cycle is divergent. But the way ModifiedPO works, every block inside the cycle gets marked as a join block. This is okay, because the exits get labelled as themselves which allows the traversal to find actual joins outside (or beyond) the cycle.
So when we want to check a join block inside a cycle C relative to a divergent branch outside of C, we should first check if there is an irreducible parent of C that does not contain the branch. If there is such a parent, then whether C is reducible is not relevant. If there is no irreducible parent, then we can check if C is reducible.
Returning early like the current code, by just checking the parent cycle looks like a bug because it fails to return the irreducible parent as the "cycle made divergent". But other join blocks in the irreducible parent will cause it to be eventually reported, so it's okay.