-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Uniformity Analysis: incorrect control-divergence result. #137277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The issue seems to be "early stop" logic inside GenericUniformityImpl.h/computeJoinPoints(), in which it uses FloorIdx to check early exit. That code seems to be from the previous code (no longer in the llvm trunk):
The original
This code was later to be refactored to support irreducible CFG (I think) from the following: If adding the following and the it can work correct.
|
I'd like to work on a fix. Could someone change it to "good first issue" and assign it to jgu222. thx |
Hi Junjie, apologies for the late reply! I have reassigned the issue to you. Please feel very welcome at contributing a fix! |
Adding @nhaehnle. I believe the initial analysis is correct. There is a problem with the early exit criterion that tracks the The implemented approach happens to work only when there is at most one block on each path between a branch and its join block. It seems that this assumption was true for most uses of UniformityAnalysis where it matters, which is the AMDGPU backend. That's why it was never noticed until now. The correct solution is to set FloorIdx to the immediate post-dominator of [Informational note: Separately, the current implementation will work if the CFG is reconverging, i.e., one successor of every branch post-dominates the other successor of the branch. Maybe that was the assumption in the original code, but that assumption was never true when we submitted this implementation upstream.] |
Yes, setting FloorIdx to the IPD of But my local patch have two failures on lit tests, both are for irreducible tests. Looks to me that the irreducible cycles do not have head-rewired cycles done when doing propagation (not sure if they should be). |
Control-divergence finds joins by propagating labels from the divergent control branch. The code that checks the early stop for propagation is not correct in some cases. This change fixes this issue by stopping at the post-dominator of the successors of the divergent branch. llvm#137277
New PR : #139667 (old one is closed). Basically try to stop at the immediate post-dominator of divergent branch's successors. For a reducible graph, the way to check if it is the IPD is to check if there is only one block in FreshLabels. Not faimiliar with the analysis of irreducible graph, so the change lets the code to propagate through the entire irreducible cycles until the node are no longer inside irreducible cycle. @ssahasra , please help check if it makes sense. |
The uniform analysis fails to recognize PHI node as divergence.
The test (phi_issue.ll) using AMDGPU to get divergence branch. The uniformity
analysis marks all PHI nodes at B6 as uniform, which is incorrect.
Basically, it is the following simple if-then-else (except there are multiple
basic blocks in both then and else brances):
x is marked as UNIFORM, which is incorrect as div-if is divergent branch
The text was updated successfully, but these errors were encountered: