Skip to content

Commit 1e5d87b

Browse files
committed
[FIRRTL] Clarify SubOfPad signedness comment
Assisted-by: Claude Code:claude-opus-5-5
1 parent 1bb8b99 commit 1e5d87b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎include/circt/Dialect/FIRRTL/FIRRTLCanonicalization.td‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,16 @@ def SubOfSelf : Pat <
329329
[(KnownWidth $x)]>;
330330

331331
// sub((pad a, n), b) -> pad(sub(a, b), n)
332-
// Only valid for signed operands: a negative unsigned difference would be
333-
// zero-extended instead of sign-extended.
332+
// Only valid when the padded operand is signed: a negative unsigned difference
333+
// would be zero-extended instead of sign-extended. Both sub operands share a
334+
// signedness, so checking a is enough.
334335
def SubOfPadL : Pat <
335336
(SubPrimOp:$old (PadPrimOp $a, $m), $b),
336337
(MoveNameHint $old, (PadPrimOp (SubPrimOp $a, $b), (TypeWidth32 $old))),
337338
[(KnownWidth $a), (KnownWidth $b), (SIntType $a)]>;
338339

339340
// sub(b, (pad a, n)) -> pad(sub(b, a), n)
340-
// Only valid for signed operands, see SubOfPadL.
341+
// Only valid when the padded operand is signed, see SubOfPadL.
341342
def SubOfPadR : Pat <
342343
(SubPrimOp:$old $b, (PadPrimOp $a, $m)),
343344
(MoveNameHint $old, (PadPrimOp (SubPrimOp $b, $a), (TypeWidth32 $old))),

0 commit comments

Comments
 (0)