This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an error with negating a negative SInt literal and a
[debatable] lint warning in Verilator when negating any value.
This behavior matches that of Chisel (which directly emits the 0 - x
already).
Fixes #2026 although it introduces a new lint warning for that case
Fixes #2031
Follow on work to do constant propagation on subtraction (which we somehow are still not doing) which will fix the introduced lint warning (but a lint warning is better than an error!)
Contributor Checklist
Type of Improvement
API Impact
Depending on
Legalize
means a transform will no longer seeNeg
prim ops.Backend Code Generation Impact
This changes the emission of
neg
from:to
As described in #2031, Verilator has a lint warning on this (warnings default to error). I don't agree with the lint warning, but since Chisel doesn't emit
neg
anyway (instead emitting0 - x
like this change), I think matching the behavior of Chisel is fine.We should consider seeing if Verilator might change that warning though.
Desired Merge Strategy
Release Notes
Canonicalize
neg(x)
to0 - x
. Fix bug where negated negative literal would result in invalid Verilog.Reviewer Checklist (only modified by reviewer)
Please Merge
?