<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>269509</bug_id>
          
          <creation_ts>2024-02-15 14:09:28 -0800</creation_ts>
          <short_desc>Wrong chain F{32,64}Sub + F{32,64}Copysign when rhs is NaN in BBQ JIT mode</short_desc>
          <delta_ts>2024-02-16 23:04:07 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebAssembly</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marcus Plutowski">marcus_plutowski</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2014137</commentid>
    <comment_count>0</comment_count>
    <who name="Marcus Plutowski">marcus_plutowski</who>
    <bug_when>2024-02-15 14:09:28 -0800</bug_when>
    <thetext>rdar://120780768

Tested on commit 9fb944e082ca85e9c509d60d879e898476822bd8.

Below the Poc:

```
// (module
//     (type (func (param f64) (result f64)))
//     (func (type 0) (local f64)
//         (local.set 1 (local.get 0))
//         (local.set 0 (f64.sub (local.get 0) (f64.const nan)))
//         (local.set 1 (f64.copysign (local.get 1) (local.get 0)))
//         (local.get 1)
//     )
//   (export &quot;poc&quot; (func 0))
// )

const wasm_code = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 124, 1, 124, 3, 2, 1, 0, 7, 7, 1, 3, 112, 111, 99, 0, 0, 10, 33, 1, 31, 1, 1, 124, 32, 0, 33, 1, 32, 0, 68, 0, 0, 0, 0, 0, 0, 248, 127, 161, 33, 0, 32, 1, 32, 0, 166, 33, 1, 32, 1, 11]);
try {
    const wasm_mod = new WebAssembly.Module(wasm_code);
    const wasm_instance = new WebAssembly.Instance(wasm_mod);
    let ret = undefined;
    for (let i = 0; i &lt; 10000; i++) {
        ret = wasm_instance.exports.poc(1234);
    }
    print(ret);
}
catch (e) {
    print(e);
}
```

The result is different if it&apos;s JIT&apos;ed on BBQ or not.

```
$ jsc --useConcurrentJIT=false --useBBQJIT=true --useOMGJIT=false ./poc.js
-1234

$ jsc --useWasmLLInt=true --useBBQJIT=false --useOMGJIT=false ./poc.js
1234
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014185</commentid>
    <comment_count>1</comment_count>
    <who name="Marcus Plutowski">marcus_plutowski</who>
    <bug_when>2024-02-15 15:16:58 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/24554</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2014779</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-02-16 23:04:06 -0800</bug_when>
    <thetext>Committed 274910@main (5f1ac6454783): &lt;https://commits.webkit.org/274910@main&gt;

Reviewed commits have been landed. Closing PR #24554 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>