Skip to content

SSA shuffler: "all necessary slots reachable" should ignore junk#16609

Merged
clonker merged 2 commits intodevelopfrom
ssa-shuffler-all-necessary-slots-reachable-should-ignore-junk
Apr 19, 2026
Merged

SSA shuffler: "all necessary slots reachable" should ignore junk#16609
clonker merged 2 commits intodevelopfrom
ssa-shuffler-all-necessary-slots-reachable-should-ignore-junk

Conversation

@clonker
Copy link
Copy Markdown
Member

@clonker clonker commented Apr 18, 2026

Added three tests, where the stack top is either a variable, a lit, or junk and the stack has to grow by one to populate it. For the first two, the shuffler pulls the var/lit out of the tail by shrinking and then growing back; for junk it should simply push0 (when it was previously oscillating).


auto const& targetArg = _state.targetArg(offset);
// if the target arg is junk, we can simply push0 and it's fine
if (targetArg.isJunk())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this condition should in the future, i think, be extended to "is it junk or a lit that is cheap to push or we don't care about bytecode size and simply want fast execution"

@clonker clonker requested a review from blishko April 18, 2026 07:27
@clonker clonker marked this pull request as ready for review April 18, 2026 07:28
Comment on lines +1 to +4
initial: [lit1, lit1, v0, v0, lit0, v0, lit0, v0, v0, v0, lit0, v0, v0, v0, lit0, v0, lit0, lit0, v0]
targetStackTop: [JUNK, lit0, v0, lit0, v0, JUNK, v0, lit0, JUNK, v0, v0, lit0, v0, JUNK, lit0, v0, lit1]
targetStackTailSet: {v0}
targetStackSize: 20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am a bit confused.
Why is it trying to reach for lit1 instead of just doing PUSH lit1?
This should be just one instruction, similar to the JUNK case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, now I understand your comment.
PUSH lit1 is potentially expensive, if lit1 is large.
As you say, at some point it would be good to come up with some heuristic to re-create the literal instead of trying to dup/swap existing one.

@clonker clonker merged commit 2282b93 into develop Apr 19, 2026
84 checks passed
@clonker clonker deleted the ssa-shuffler-all-necessary-slots-reachable-should-ignore-junk branch April 19, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants