[FIRRTL] Fix mask repeat order in FlattenMemory#10106
Open
[FIRRTL] Fix mask repeat order in FlattenMemory#10106
Conversation
Use mask width lookup aligned with FIRRTL bit index order when expanding aggregate masks in FlattenMemory.\n\nAlso update and extend flatten-memory regression checks, including a MaskRepeatOrder case and adjusted expectations for corrected mask mapping.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect ordering when repeating/expanding aggregate memory mask bits during FlattenMemory, ensuring repetition counts align with FIRRTL bit ordering (MSB→LSB) rather than raw bit indices.
Changes:
- Adjust mask-bit repetition to use a reverse index mapping when looking up repetition counts.
- Update existing FileCheck patterns to reflect the corrected concatenation order.
- Add a regression test covering a compact mixed-width aggregate mask expansion case.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/Dialect/FIRRTL/flatten-memory.mlir | Updates existing checks for corrected mask concatenation order and adds a new regression module @MaskRepeatOrder. |
| lib/Dialect/FIRRTL/Transforms/FlattenMemory.cpp | Fixes repetition-count lookup by reversing the index used to access maskWidths during mask expansion. |
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.
Fixes #10105
Summary
Fix incorrect mask-bit repetition ordering in FlattenMemory when expanding aggregate memory masks.
The previous logic indexed repetition counts by FIRRTL bit index directly, while maskWidths is ordered MSB-to-LSB. This mismatch could assign repetition counts to the wrong mask bits for mixed-width aggregates.
Changes
Validation
Assisted-by
My role: Reviewed and assumed responsibility for all AI-generated content, with minor textual refinements.