Set exact flag on index_castui during iree-util-optimize-int-arithmetic#23667
Closed
amd-eochoalo wants to merge 4 commits intoiree-org:mainfrom
Closed
Set exact flag on index_castui during iree-util-optimize-int-arithmetic#23667amd-eochoalo wants to merge 4 commits intoiree-org:mainfrom
amd-eochoalo wants to merge 4 commits intoiree-org:mainfrom
Conversation
Contributor
Author
|
Converting back to draft. I'll add exact instead on one of the passes like |
4271cb5 to
ee7db1d
Compare
kuhar
reviewed
Mar 5, 2026
kuhar
approved these changes
Mar 5, 2026
Contributor
Author
|
@RattataKing I'll merge after your LLVM integration, so no need to worry about this PR. I'll also point to the new LLVM branch. |
Contributor
|
I'm going to flag that these patterns also exist upstream, and that there are a few other spots in IREE where we generate index_cast ops. |
Contributor
Author
|
I'm closing this without merging due to it being reverted upstream. See llvm/llvm-project#184876 |
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.
Since llvm/llvm-project#183395 was merged upstream,
optimization of index_cast(index_cast(x)) -> x requires the exact flag.
This pattern without the exact flag is unsound since the size of index is assumed to be 64 bits
but that is not always the case.
IREE applies this pattern when running --iree-util-optimize-int-arithmetic.
This pass uses the util dialect to prove the correctness of transforming signed operations into unsigned operations.
We take advantage of this to set the exact flag which allows the pattern to get applied soundly.