[NFC] Using orderedBefore in skipNonNullCast#8803
Merged
Merged
Conversation
When OptimizeInstructions skips explicit `ref.as_non_null` instructions because they are flowing into a parent expression that will already do a null check, it has to check that moving the trap effect past any subsequent children of the parent is allowed. Update the code to use `orderedBefore` instead of `invalidates`. This is not a functional change because traps are ordered symmetrically with other effects; a trap can be moved forward past another effect iff it can be moved backward past that other effect. The code therefore has the same behavior whether it uses `orderedBefore`, `orderedAfter`, or `invalidates` here. `orderedBefore` makes the most sense given then context, though.
stevenfontanella
approved these changes
Jun 5, 2026
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.
When OptimizeInstructions skips explicit
ref.as_non_nullinstructions because they are flowing into a parent expression that will already do a null check, it has to check that moving the trap effect past any subsequent children of the parent is allowed. Update the code to useorderedBeforeinstead ofinvalidates. Also make this change in another place that removes aref.as_non_nullin the same way.This is not a functional change because traps are ordered symmetrically with other effects; a trap can be moved forward past another effect iff it can be moved backward past that other effect. The code therefore has the same behavior whether it uses
orderedBefore,orderedAfter, orinvalidateshere.orderedBeforemakes the most sense given then context, though.