Return the original signal when replicating by 1 - #689
Merged
mkorbel1 merged 1 commit intoJul 23, 2026
Conversation
mkorbel1
requested changes
Jul 22, 2026
mkorbel1
left a comment
Contributor
There was a problem hiding this comment.
Thank you for your contribution! A couple notes/questions
`Logic.replicate(1)` built a `ReplicationOp`, which emits a redundant
`{1{...}}` in the generated SystemVerilog:
assign rep1 = {1{a}};
Replicating once is a no-op, so return the signal directly instead. The
generated output becomes:
assign rep1 = a;
`signExtend` already routes through `replicate`, so it inherits the same
benefit: sign-extending a 1-bit signal to width 1, or any signal to its
existing width, no longer emits a replication.
Validation of non-positive multipliers is unaffected; those still reach
`ReplicationOp` and throw `InvalidMultiplierException`.
Adds tests for the returned signal identity and for the absence of `{1{`
in generated SystemVerilog. The existing "multiply by 1" test only
checked simulated values, which pass either way.
Fixes intel#522
aishasalim
force-pushed
the
fix/replicate-by-one-returns-signal
branch
from
July 23, 2026 02:32
8a665c4 to
5fe5200
Compare
mkorbel1
approved these changes
Jul 23, 2026
mkorbel1
left a comment
Contributor
There was a problem hiding this comment.
Looks great! Thank you for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Logic.replicate(1)built aReplicationOp, which emits a redundant{1{...}}in the generated SystemVerilog:Replicating once is a no-op, so return the signal directly instead. The generated output becomes:
signExtendalready routes throughreplicate, so it inherits the same benefit: sign-extending a 1-bit signal to width 1, or any signal to its existing width, no longer emits a replication.Validation of non-positive multipliers is unaffected; those still reach
ReplicationOpand throwInvalidMultiplierException.Adds tests for the returned signal identity and for the absence of
{1{in generated SystemVerilog. The existing "multiply by 1" test only checked simulated values, which pass either way.Fixes #522
Description & Motivation
Related Issue(s)
Testing
Backwards-compatibility
Documentation