Fix v128.load_lane missing lane clear before OR#566
Merged
titzer merged 3 commits intotitzer:masterfrom Mar 4, 2026
Merged
Conversation
doLoadLane ORs the loaded value into the target lane without clearing existing bits first. This means if the lane already has non-zero bits, the result is incorrect (old | new instead of just new). Fix by computing a lane-width mask and using (old & ~mask) | new to properly replace the lane contents.
b23487f to
e26795c
Compare
titzer
approved these changes
Mar 3, 2026
Owner
titzer
left a comment
There was a problem hiding this comment.
Thanks, can you submit a regression test for this case?
Verifies that v128.load8_lane properly replaces the target lane contents instead of ORing the loaded value with existing bits.
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.
Summary
doLoadLaneORs the loaded value into the target lane without clearing existing bits first, producing incorrect results when the lane already has non-zero bits (old | newinstead of replacing withnew).Details
V3Interpreter.v3:1417— the loaded value is shifted and ORed directly into the low/high u64. If the target lane had prior content, those bits are preserved incorrectly.Fix: compute a lane-width mask and use
(old & ~(mask << shift)) | (val << shift)to properly replace lane contents.