Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRRTL] FoldRegMems: insert new ops into same block as memory #7909

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

rwy7
Copy link
Contributor

@rwy7 rwy7 commented Nov 27, 2024

Before this PR, FoldRegMems would construct new ops in the "body of the parent FModuleOp". We need to place these ops in the same block as the memory.

This PR fixes a bug where, when a memory under a layerblock was canonicalized to a register, the register would be placed at the original location of the memory (under the layerblock), but its readers would be placed outside the layerblock, resulting in a dominance checking error.

@rwy7 rwy7 force-pushed the fix-1element-mem-to-reg-canonicalizer branch from 0dcc799 to 07eb2f5 Compare November 27, 2024 02:19
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see utility and simplicity in this approach of relocating the register to the end. This will likely produce worse Verilog in the output unless a later pass comes and reorders things to remove the temporary wire. That said, this optimization is so rare anyway and this patch fixes a known bug re: layers.

LGTM

// CHECK: firrtl.matchingconnect %Memory, {{%.+}} : !firrtl.uint<32>
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same review comments as last time for the test. The layer test is large. Can it be made smaller by either: (1) removing connections or (2) reducing the number of ports?

Before this PR, FoldRegMems would construct new ops in the "body of the parent
FModuleOp". We need to place these ops in the same block as the memory.

This PR fixes a bug where, when a memory under a layerblock was canonicalized
to a register, the register would be placed at the original location of the
memory (under the layerblock), but its readers would be placed outside the
layerblock, resulting in a dominance checking error.
@rwy7 rwy7 force-pushed the fix-1element-mem-to-reg-canonicalizer branch from 07eb2f5 to b3c81d0 Compare November 27, 2024 19:24
@rwy7 rwy7 merged commit 4ca5ab5 into llvm:main Nov 27, 2024
4 checks passed
@rwy7 rwy7 deleted the fix-1element-mem-to-reg-canonicalizer branch November 27, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants