Skip to content

llvm-reduce: Avoid removing convergent with convergence tokens #132946

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

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Mar 25, 2025

Check if the intrinsics are declared in the module as an overly
conservative fix.

Fixes #132695

Check if the intrinsics are declared in the module as an overly
conservative fix.

Fixes #132695
Copy link
Contributor Author

arsenm commented Mar 25, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review March 25, 2025 15:39
AttributeRemapper(Oracle &O, LLVMContext &C) : O(O), Context(C) {}
AttributeRemapper(Oracle &O, Module &M) : O(O), Context(M.getContext()) {

// Check if there are any convergence intrinsics used. We cannot remove the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not strip the control token along with the convergent attribute? The only place you can't strip a token is when it is the operand of the loop intrinsic, unless previous reductions make the loop intrinsic itself unused and it can be eliminated entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reduction only is touching the attributes and should touch nothing else. It should only avoid doing something that will fail the verifier from the uses that require it. Deletion of the uses that may require the tokens is for another reduction pass

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the last part of my comment about uses of the loop intrinsic was a distraction. My point is that the convergence control token can be viewed as an improvement over the convergent intrinsic, to the point that the intrinsic will become redundant if tokens are used everywhere. The token does not itself participate in control flow or data flow. In that sense, deleting the token on a convergent call while removing the convergent attribute is a valid interpretation of what this pass is doing. Even if we made a separate pass that removes token operands, that pass must remove the convergent attribute to keep the IR valid. Then we might as well do both right here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of the reduction is not remove the attribute at any cost. Any change in the reproducer is more likely related to the side effect of hacking on the actual instructions, not the attribute removal. It's not written to do so, nor should it be. Attributes that impose structural restrictions on the IR are problematic. It is fine to just ignore it.

@arsenm arsenm merged commit 0ed8b27 into main Mar 28, 2025
15 checks passed
@arsenm arsenm deleted the users/arsenm/llvm-reduce/avoid-removing-convergent-with-convergence-tokens branch March 28, 2025 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

llvm-reduce's attribute reduction should not try to remove convergent attribute if convergence tokens are in used
2 participants