Repository navigation
[FIX][S-TIR] Preserve loop variable types when eliminating unit-extent loops - #20999
Merged
Merged
Conversation
Contributor
Author
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change preserving integer types during unit-extent loop elimination.
No open issues 🎉
What changed in this PR
Updates S-TIR’s LoopPartition pass to preserve integer types when eliminating unit-extent loops, addressing the type mismatch reported in #20879.
Changes:
- Constructs replacement zeros using the original loop variable’s type.
- Adds int32/int64 regression tests checking loop elimination and matching addition operand types.
| File | Description |
|---|---|
tests/python/s_tir/transform/test_s_tir_transform_loop_partition.py |
Adds parameterized regression coverage for type-safe loop elimination. |
src/s_tir/transform/loop_partition.cc |
Preserves the loop variable’s type in the replacement zero. |
Review effort: Max
Contributor
Author
|
Hi @mshr-h, thanks for arranging the Copilot review. It reported no issues, and this PR is still awaiting a maintainer review. Could you please take a look when you have a chance, or suggest an appropriate reviewer? Thank you! |
mshr-h
approved these changes
Nov 19, 2026
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.
LoopPartition replaces unit-extent loop variables with an int32 zero, regardless of the original variable type. For int64 loops, this can produce addition expressions with mismatched int32/int64 operands.
Construct the replacement zero using the loop variable's type.
Add int32/int64 regression tests that check unit loops are eliminated without introducing mismatched addition operands. The int64 case fails before the fix and passes afterward.
The immediate substitution error reported in #20879 was not reproduced on this checkout; instead, the pass produced expressions with mismatched operand types. The regression test checks this type inconsistency.
Fixes #20879.