Repository navigation
Folding util.assume.int values that have a single possible value. - #21025
Merged
Merged
Conversation
This commonly arises in dynamic resource offsets on stream bindings: a bunch of `umin=0, umax=0` (or whatever offset) values that ugly up the IR.
benvanik
marked this pull request as ready for review
June 5, 2025 23:35
benvanik
enabled auto-merge (squash)
June 5, 2025 23:35
qedawkins
approved these changes
Jun 6, 2025
| } else if (auto assumption = dyn_cast<IREE::Util::IntAssumptionAttr>( | ||
| assumptions.getValue().front())) { | ||
| if (assumption.getUmin().has_value() && assumption.getUmax().has_value() && | ||
| assumption.getUmin() == assumption.getUmax()) { |
Contributor
There was a problem hiding this comment.
If you want to maximize the folding possibilities, we can do
int64_t udiv = assumption.getUdiv().value_or(1);
int64_t nearestUminCeil = (udiv + assumption.getUmin() - 1) / udiv;
if (assumption.getUmin() + udiv > assumption.getUmax()) {
return nearestUminCeil;
}
To also catch small ranges with large divisibilities. I doubt we hit such cases in practice though.
Another way to do the same is composing with a canonicalization pattern that clamps umin/umax to their nearest divisible neighbors in which case this folder will kick in automatically.
Contributor
There was a problem hiding this comment.
Actually doing the canonicalization might be better to keep this logic simpler.
Collaborator
Author
There was a problem hiding this comment.
interesting! if you spot these in nature let me know!
AWoloszyn
pushed a commit
that referenced
this pull request
Dec 1, 2025
…1025) This commonly arises in dynamic resource offsets on stream bindings: a bunch of `umin=0, umax=0` (or whatever offset) values that ugly up the IR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commonly arises in dynamic resource offsets on stream bindings: a bunch of
umin=0, umax=0(or whatever offset) values that ugly up the IR.