Repository navigation
Commit 1bb8b99
committed
Only narrow signed subtraction in SubOfPad canonicalizers
SubOfPadL/R rewrite sub(pad(a, n), b) into pad(sub(a, b), n). That is
only correct for signed operands. For UInt the narrower difference is
zero-extended, so a negative result loses its high bits, e.g. a 9-bit
zero-extended a minus c gave a 10-bit result with bit 9 always zero.
Restrict both patterns to SInt and update the sub_narrow test, which was
checking the wrong result.
Assisted-by: Codex:gpt-6.1-sol
Assisted-by: Claude Code:claude-opus-5-51 parent a034e7d commit 1bb8b99
2 files changed
Lines changed: 15 additions & 11 deletions
File tree
- include/circt/Dialect/FIRRTL
- test/Dialect/FIRRTL
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
335 | | - | |
| 337 | + | |
336 | 338 | | |
337 | 339 | | |
| 340 | + | |
338 | 341 | | |
339 | 342 | | |
340 | 343 | | |
341 | | - | |
| 344 | + | |
342 | 345 | | |
343 | 346 | | |
344 | 347 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2361 | 2361 | | |
2362 | 2362 | | |
2363 | 2363 | | |
| 2364 | + | |
| 2365 | + | |
2364 | 2366 | | |
2365 | | - | |
2366 | | - | |
2367 | | - | |
2368 | | - | |
2369 | | - | |
2370 | | - | |
2371 | | - | |
2372 | | - | |
2373 | | - | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
2374 | 2375 | | |
2375 | 2376 | | |
2376 | 2377 | | |
| |||
0 commit comments