Skip to content

Fix v128.load_lane missing lane clear before OR#566

Merged
titzer merged 3 commits intotitzer:masterfrom
sumleo:fix/load-lane-missing-clear
Mar 4, 2026
Merged

Fix v128.load_lane missing lane clear before OR#566
titzer merged 3 commits intotitzer:masterfrom
sumleo:fix/load-lane-missing-clear

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 25, 2026

Summary

  • doLoadLane ORs the loaded value into the target lane without clearing existing bits first, producing incorrect results when the lane already has non-zero bits (old | new instead of replacing with new).

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.

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.
@sumleo sumleo force-pushed the fix/load-lane-missing-clear branch from b23487f to e26795c Compare February 25, 2026 14:34
Copy link
Owner

@titzer titzer left a comment

Choose a reason for hiding this comment

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

Thanks, can you submit a regression test for this case?

sumleo and others added 2 commits March 4, 2026 20:25
Verifies that v128.load8_lane properly replaces the target lane contents
instead of ORing the loaded value with existing bits.
@titzer titzer merged commit d682b66 into titzer:master Mar 4, 2026
12 checks passed
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