Skip to content

Fix aliasing with scratch register on 32-bit bbq i64 div - #1707

Open
justinmichaud wants to merge 1 commit into
WebPlatformForEmbedded:wpe-2.46from
justinmichaud:eng/246-bbq-div
Open

Fix aliasing with scratch register on 32-bit bbq i64 div#1707
justinmichaud wants to merge 1 commit into
WebPlatformForEmbedded:wpe-2.46from
justinmichaud:eng/246-bbq-div

Conversation

@justinmichaud

@justinmichaud justinmichaud commented Aug 1, 2026

Copy link
Copy Markdown

Fix aliasing with scratch register on 32-bit bbq i64 div
3d39ac2

Build-Tests Layout-Tests
✅ 🛠 wpe-246-amd64-build ✅ 🧪 wpe-246-amd64-layout
✅ 🛠 wpe-246-arm32-build ❌ 🧪 wpe-246-arm32-layout


// The i32 operand of the outer add is evaluated first, so it holds a register while the
// dividend is loaded. That pushes the dividend into a register pair overlapping the pair
// the C call passes it in, which is what makes the argument shuffle need a temporary.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not entirely obvious what the issue with the argument shuffle needing a temporary is. Presumably it's because we place the value to be tested in the scratch registers in the needsZeroCheck case in emitModOrDiv (so we're assuming that the shuffle won't need the temporary), but this comment read pretty mysterious to me in this file :-)

}

// A zero dividend with a non-zero constant divisor emits no zero check, so losing the
// divisor makes the runtime helper divide zero by zero and take SIGFPE.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similarly, I puzzled over "losing the divisor" here. IIUC this comment assumes the bug that's fixed by this commit. Perhaps "exercise the elided zero-check on the divisor"?

@aoikonomopoulos

Copy link
Copy Markdown

Now that I get it, looks obviously correct to me. It's a shame we're not threading the "you can't use a temporary here" assumption to emitShuffleMove (or not using some other way of detecting that).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants