<?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>272901</bug_id>
          
          <creation_ts>2024-04-18 09:42:29 -0700</creation_ts>
          <short_desc>[WASM] Avoid extraneous move for simple integer arithmetic in BBQ</short_desc>
          <delta_ts>2024-04-21 13:47:39 -0700</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>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=273048</see_also>
          <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="David Degazio">d_degazio</reporter>
          <assigned_to name="David Degazio">d_degazio</assigned_to>
          <cc>fujii</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2029486</commentid>
    <comment_count>0</comment_count>
    <who name="David Degazio">d_degazio</who>
    <bug_when>2024-04-18 09:42:29 -0700</bug_when>
    <thetext>When we emit various simple integer arithmetic instructions in BBQ with a constant operand, we currently use the MacroAssembler API pretty pessimistically, for example in i32.add:

    m_jit.move(ImmHelpers::regLocation(lhsLocation, rhsLocation).asGPR(), resultLocation.asGPR());
    m_jit.add32(Imm32(ImmHelpers::imm(lhs, rhs).asI32()), resultLocation.asGPR());

It&apos;s well-supported in our MacroAssembler to perform a three-operand add (and other arithmetic instructions) even on platforms like x86, so we should just use that. It should save us from obviously redundant codegen like the following on ARM:

    mov x1, x0
    add x1, x1, #1

...and allow us to use instructions like lea on x86 to accomplish much the same.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2029487</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-04-18 09:42:58 -0700</bug_when>
    <thetext>&lt;rdar://problem/126695575&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2029508</commentid>
    <comment_count>2</comment_count>
    <who name="David Degazio">d_degazio</who>
    <bug_when>2024-04-18 10:45:41 -0700</bug_when>
    <thetext>*** Bug 272902 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2029587</commentid>
    <comment_count>3</comment_count>
    <who name="David Degazio">d_degazio</who>
    <bug_when>2024-04-18 14:13:39 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/27473</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2029993</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-04-19 17:09:15 -0700</bug_when>
    <thetext>Committed 277770@main (7a2375d28da4): &lt;https://commits.webkit.org/277770@main&gt;

Reviewed commits have been landed. Closing PR #27473 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2030111</commentid>
    <comment_count>5</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2024-04-21 13:47:39 -0700</bug_when>
    <thetext>Regressed: Bug 273048 – REGRESSION(277770@main): [Mac WK1, GTK, WPE, Win] ASSERTION FAILED: v &lt;= 0 under MacroAssemblerX86Common::sub32</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>