<?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>192073</bug_id>
          
          <creation_ts>2018-11-28 00:21:34 -0800</creation_ts>
          <short_desc>[JSC] FTL should not load arguments twice for type check and use for non-full-64bit values</short_desc>
          <delta_ts>2023-06-02 18:42:29 -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>JavaScriptCore</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="Saam Barati">saam</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>benjamin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>rmorisset</cc>
    
    <cc>ticaiolima</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1482377</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-11-28 00:21:34 -0800</bug_when>
    <thetext>We end up loading the arguments twice just to have the second loads be 32-bit loads. We shouldn&apos;t have to do this.

a &amp; b are ints:
```
function foo(a, b) {
    return a + b;
}
```

Generates:
```
0x4c04f0c024ed: mov 0x38(%rbp), %rcx
0x4c04f0c024f1: mov $0xffff000000000000, %rax
0x4c04f0c024fb: cmp %rax, %rcx
0x4c04f0c024fe: jb 0x4c04f0c02595
0x4c04f0c02504: mov 0x30(%rbp), %rcx
0x4c04f0c02508: cmp %rax, %rcx
0x4c04f0c0250b: jb 0x4c04f0c0259f
0x4c04f0c02511: mov 0x30(%rbp), %ecx
0x4c04f0c02514: mov 0x38(%rbp), %edx
0x4c04f0c02517: add %ecx, %edx
0x4c04f0c02519: jo 0x4c04f0c025b3
0x4c04f0c0251f: add %rdx, %rax
0x4c04f0c02526: ret 
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1482426</commentid>
    <comment_count>1</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2018-11-28 07:26:40 -0800</bug_when>
    <thetext>And the FTL is emitting the loads twice?

This could be restated as an FTL lowering bug. But I agree that CSE should be smart enough to manufacture a Trunc on the originally loaded value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1496362</commentid>
    <comment_count>2</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-01-20 13:05:54 -0800</bug_when>
    <thetext>(In reply to Filip Pizlo from comment #1)
&gt; And the FTL is emitting the loads twice?
Yeah it could, but it&apos;d be awkward to do this in the FTL since the first loads are for proving argument types. I think it&apos;d be nicer if B3 were just smart enough to do this.\

&gt; 
&gt; This could be restated as an FTL lowering bug. But I agree that CSE should
&gt; be smart enough to manufacture a Trunc on the originally loaded value.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959368</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-06-01 10:26:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/110121633&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959369</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-06-01 10:29:05 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/14592</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1959648</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-06-02 18:42:26 -0700</bug_when>
    <thetext>Committed 264846@main (4b922ed02257): &lt;https://commits.webkit.org/264846@main&gt;

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

    </bug>

</bugzilla>