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] fix missing type conversion in FoldRegMems #7911

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

unlsycn
Copy link
Contributor

@unlsycn unlsycn commented Nov 27, 2024

@unlsycn unlsycn force-pushed the fix-fold-reg-mem branch 2 times, most recently from 8420ead to 8c5cad8 Compare November 27, 2024 18:49
Signed-off-by: unlsycn <unlsycn@unlsycn.com>
@rwy7
Copy link
Contributor

rwy7 commented Nov 27, 2024

Hi, the underlying issue seems to be in FoldUnusedBits (introduced in #4652), a different memory canonicalizer, which wasn't correctly handling signed data in a memory. The bitcast op added in this PR hides the problem. We found a different way to produce the error which does not involve the 1-element-memory -> register fold. I have a different fix over here #7913, please take a look!

Thanks for all your help!

@unlsycn
Copy link
Contributor Author

unlsycn commented Nov 28, 2024

Hi, the underlying issue seems to be in FoldUnusedBits (introduced in #4652), a different memory canonicalizer, which wasn't correctly handling signed data in a memory. The bitcast op added in this PR hides the problem. We found a different way to produce the error which does not involve the 1-element-memory -> register fold. I have a different fix over here #7913, please take a look!

Thanks for all your help!

Hi, thanks for your explanation! #7913 won't fix chipsalliance/chisel#4536 since the actual lack of type cast in the original issue is that dataPart and nextPart produced by firrtl.bits are unsigned but connect to the signed mem. While #7913 is obviously a nice patch, it doesn't seems to be related to this issue.

Signed-off-by: unlsycn <unlsycn@unlsycn.com>
@rwy7
Copy link
Contributor

rwy7 commented Nov 28, 2024

Ugh, thanks, looks like I managed to golf the example to a different issue, sorry. I think you're right. Do you think it makes more sense to cast when applying the mask, right here: https://github.com/llvm/circt/blob/main/lib/Dialect/FIRRTL/FIRRTLFolds.cpp#L3036

Either way, LGTM.

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.

chisel3.util.Queue not working with SInt
2 participants