Closed Bug 1953381 Opened 12 days ago Closed 10 days ago

Wasm/SIMD _mm_blendv_epi8 yields incorrect result

Categories

(Core :: JavaScript: WebAssembly, defect, P1)

Firefox 136
x86_64
All
defect

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 137+ fixed
firefox136 --- wontfix
firefox137 --- fixed
firefox138 --- fixed

People

(Reporter: llyzs.vic, Assigned: yury)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Attached file wasmtest.zip

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Steps to reproduce:

Open the attached web page which will load the WebAssembly and run the test.

The test use _mm_blendv_epi8 and a mask (0xFF 0xFF 0xFF 0x00) to blend two sources (0xFF 0x00 0x00 0xFF and 0x00 0xFF 0x00 0x00) which should yield the expected result 0x00 0xFF 0x00 0xFF.

The bug is likely related to _mm_blendv_epi8 because replacing it with _mm_add_epi8 will give the expected result (0xFF 0xFF 0x00 0xFF).

The bug also seems only reproducible when the C++ program is compiled at least at optimization level 2.

Actual results:

Test failed because the calculated result is incorrect (0xFF 0x00 0x00 0x00).

Expected results:

The test should have passed.

The Bugbug bot thinks this bug should belong to the 'Core::JavaScript: WebAssembly' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → JavaScript: WebAssembly
Product: Firefox → Core

Can confirm the test failing in Firefox and passing in Chrome.
Can repro on a build from Jan2023, so not a new regression.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(ydelendik)
Flags: needinfo?(rhunt)

Yury, can you take a look?

Assignee: nobody → ydelendik
Flags: needinfo?(rhunt)
Severity: -- → S2
Priority: -- → P1

It is specific to X86 only -- we implemented PBLEND optimizations wrong. I'll add tests. We probably want to uplift it as much as we can

Flags: needinfo?(ydelendik)
OS: Unspecified → All
Hardware: Unspecified → x86_64

Comment on attachment 9471500 [details]
Bug 1953381 - Fix x86 PBLEND optimizations for v128.bitselect. r?jseward

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Wrong results in some programs that are using wasm v128.bitselect instruction
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Trivial fix, modifies only affected operation
  • String changes made/needed:
  • Is Android affected?: Unknown

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Wrong results in some programs that are using wasm v128.bitselect instruction
  • User impact if declined:
  • Fix Landed on Version:
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Trivial fix, modifies only affected operation
Attachment #9471500 - Flags: approval-mozilla-esr128?
Attachment #9471500 - Flags: approval-mozilla-beta?
Pushed by ydelendik@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2bcb074c9bdb Fix x86 PBLEND optimizations for v128.bitselect. r=jseward
Status: NEW → RESOLVED
Closed: 10 days ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch

Comment on attachment 9471500 [details]
Bug 1953381 - Fix x86 PBLEND optimizations for v128.bitselect. r?jseward

=> 137 Beta 6

Attachment #9471500 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9471500 - Flags: approval-mozilla-esr128? → approval-mozilla-esr128+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: