[Codegen] Remove ROCDL index==i32; add indexIsI64 to OptimizeIntArithmetic#23948
Merged
krzysz00 merged 2 commits intoiree-org:mainfrom Apr 4, 2026
Merged
[Codegen] Remove ROCDL index==i32; add indexIsI64 to OptimizeIntArithmetic#23948krzysz00 merged 2 commits intoiree-org:mainfrom
krzysz00 merged 2 commits intoiree-org:mainfrom
Conversation
Contributor
Author
|
…metic Integer range analysis now handles narrowing to i32 where safe, making the --iree-rocm-index-bits option (which lowered all ROCDL indices to 32-bit) obsolete. Remove it so the ROCDL path matches NVVM (which always has 64-bit indices at the LLVM conversion level). Add an indexIsI64 option to OptimizeIntArithmeticPass that relaxes the SAFE_INDEX_UNSIGNED_MAX_VALUE guard on signed-to-unsigned conversions for index values. On LLVMGPU targets where index is always 64-bit, this guard is unnecessarily conservative and blocks valid optimizations. For-loop IV narrowing (NarrowSCFForIvToI32 retains its own range checks unconditionally.) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d7e3f28 to
8406542
Compare
| } | ||
| if (!staticallyLegalToConvertToUnsigned(solver, iv)) { | ||
| if (!staticallyLegalToConvertToUnsigned(solver, iv, | ||
| /*indexIsI64=*/false)) { |
Contributor
There was a problem hiding this comment.
Here and the other use below shouldnt you plumb through the pass option indexIsI64 rather than hard-coding false? Also maybe the test checks need to be improved if they didnt catch this?
Contributor
Author
There was a problem hiding this comment.
This is a weird one - it is specifically meant to handle narrowing to i32, so we do want the safety check
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.
Integer range analysis now handles narrowing to i32 where safe, making the --iree-rocm-index-bits option (which lowered all ROCDL indices to 32-bit) obsolete. Remove it so the ROCDL path matches NVVM (which always has 64-bit indices at the LLVM conversion level).
Add an indexIsI64 option to OptimizeIntArithmeticPass that relaxes the SAFE_INDEX_UNSIGNED_MAX_VALUE guard on signed-to-unsigned conversions for index values. On LLVMGPU targets where index is always 64-bit, this guard is unnecessarily conservative and blocks valid optimizations. For-loop IV narrowing (NarrowSCFForIvToI32 retains its own range checks unconditionally.)
Performance impact: on whole models, within the noise floor (as expected, this killed off a few instructions) but there is a consistent minor trend on the torch_models CI that gives a 1.01x geometric mean speedup, so there's not much reason not to do this. Table below.