Skip to content

[NFC] Simplify a bit of logic in RemoveUnusedBrs#8603

Merged
kripken merged 2 commits intoWebAssembly:mainfrom
kripken:rubr.redirect.subt
Apr 14, 2026
Merged

[NFC] Simplify a bit of logic in RemoveUnusedBrs#8603
kripken merged 2 commits intoWebAssembly:mainfrom
kripken:rubr.redirect.subt

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Apr 14, 2026

The checks in the old code were not needed: we have a block that
has a single child, another block. Any branch to the child sends a
value that flows out to the parent immediately. No circumstances
exist in which we can error.

(block $outer
  (block $inner
    ..code and a br to $inner, which can branch to $outer instead..
  )
)

Also, this code only handles blocks without a value, so even
subtyping is not an issue here. (Merging blocks with different
types is handled elsewhere, RemoveUnusedNames, so no
need to add new logic here.)

Background:

https://github.com/WebAssembly/binaryen/pull/8398/changes/BASE..82441de8882abbac2a83bd88596c985d8c093b8e#r2861953106

@kripken kripken requested a review from tlively April 14, 2026 22:35
@kripken kripken requested a review from a team as a code owner April 14, 2026 22:35
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

LGTM. Is it possible to find a test where would optimize now but not optimize before? Where the inner block result is a subtype of the outer block result, perhaps?

@kripken
Copy link
Copy Markdown
Member Author

kripken commented Apr 14, 2026

No, see this code only handles blocks without a value - this does not even run on blocks with results (another pass does those), so this is truly NFC.

@kripken kripken merged commit 2fa35d6 into WebAssembly:main Apr 14, 2026
16 checks passed
@kripken kripken deleted the rubr.redirect.subt branch April 14, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants