Skip to content

Conversation

@fabianschuiki
Copy link
Contributor

The folders and canonicalizers for comb.shl, comb.shru, and comb.shrs perform unchecked getZExtValue() calls which can crash if the shift amount does not fit into 64 bits. The shift amount is also not clamped to the width of the result, which causes the shift to be replaced with ops that have a different type.

Found with VlogHammer, which turns out to be a very handy tool!

Fixes #8694.
Fixes #8695.

The folders and canonicalizers for `comb.shl`, `comb.shru`, and
`comb.shrs` perform unchecked `getZExtValue()` calls which can crash
if the shift amount does not fit into 64 bits. The shift amount is also
not clamped to the width of the result, which causes the shift to be
replaced with ops that have a different type.

Found with [VlogHammer], which turns out to be a very handy tool!

Fixes #8694.
Fixes #8695.

[VlogHammer]: https://github.com/YosysHQ/VlogHammer
@fabianschuiki fabianschuiki added the bug Something isn't working label Jul 11, 2025
@fabianschuiki fabianschuiki requested a review from darthscsi as a code owner July 11, 2025 23:43
@fabianschuiki fabianschuiki added the Comb Involving the `comb` dialect label Jul 11, 2025
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

This makes sense to me.

@fabianschuiki fabianschuiki merged commit 7df789c into main Jul 12, 2025
7 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/comb-excessive-shifts branch July 12, 2025 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Comb Involving the `comb` dialect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ImportVerilog] comb.shrs with operand time mismatch [Comb] divs folder produces value of incorrect type

4 participants