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

[MooreToCore] Support CaseZEq and CaseXZEq ops #7503

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

fabianschuiki
Copy link
Contributor

Add a conversion for moore.casez_eq and moore.casexz_eq operations. These only really make sense if the operands are four-valued integers, since the X and Z bits indicate which bits to ignore during the equality check. We don't have support for four-valued integers in the core dialects yet. However, the vast majority of uses of this op are comparing an SSA value against a moore.constant. This case we can handle properly by looking at the constant, identifying the unknown bits, and then masking them before performing a regular two-valued comparison between the two operands.

Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

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

Quite hacky, but the best we can do for now.

Extracting the non-Z ranges and having multiple comparisons that are then ANDed would be more efficient in HW, but I like your more simulation focussed approach 😜

lib/Conversion/MooreToCore/MooreToCore.cpp Outdated Show resolved Hide resolved
}

rewriter.replaceOpWithNewOp<comb::ICmpOp>(op, ICmpPredicate::ceq, lhs, rhs);
// rewriter.replaceOpWithNewOp<comb::SubOp>(op, zero, adaptor.getInput());
Copy link
Member

Choose a reason for hiding this comment

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

Remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, thanks!

@fabianschuiki
Copy link
Contributor Author

Extracting the non-Z ranges and having multiple comparisons that are then ANDed would be more efficient in HW, but I like your more simulation focussed approach 😜

Haha yeah, very true 😁. Some form of known-bits analysis and using its results to canonicalize comparisons could be a very neat thing. I think @dtzSiFive was talking about some of that a while ago 😍

Add a conversion for `moore.casez_eq` and `moore.casexz_eq` operations.
These only really make sense if the operands are four-valued integers,
since the X and Z bits indicate which bits to ignore during the equality
check. We don't have support for four-valued integers in the core
dialects yet. However, the vast majority of uses of this op are
comparing an SSA value against a `moore.constant`. This case we can
handle properly by looking at the constant, identifying the unknown
bits, and then masking them before performing a regular two-valued
comparison between the two operands.
@fabianschuiki fabianschuiki merged commit e871e0b into main Aug 10, 2024
4 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/m2c-casexz branch August 10, 2024 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants