<?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>142953</bug_id>
          
          <creation_ts>2015-03-22 18:28:41 -0700</creation_ts>
          <short_desc>DFG JIT code for BitAnd may be redundantly checking that the results is an int32.</short_desc>
          <delta_ts>2015-03-23 15:16:58 -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>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="dougc">dtc-llvm</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1079189</commentid>
    <comment_count>0</comment_count>
    <who name="dougc">dtc-llvm</who>
    <bug_when>2015-03-22 18:28:41 -0700</bug_when>
    <thetext>For BitAnd with a constant int32 argument the result is known to be an int32. However function &apos;int32Result()&apos; emits the int32 assertion &apos;jitAssertIsInt32(reg)&apos; that looks redundant. For example:

      87:&lt; 3:loc13&gt;	BitAnd(Int32:@76, Int32:@84, Int32|PureNum|UseAsOther|UseAsInt|ReallyWantsInt, Int32, bc#117)
          0x7f2d12000716: mov %r9, %r10
          0x7f2d12000719: and $0x7fc, %r10d
          0x7f2d12000720: mov $0xffffffff, %r11  ; redundant int32 assertion?
          0x7f2d1200072a: cmp %r11, %r10
          0x7f2d1200072d: jbe 0x7f2d1200073a
          0x7f2d12000733: mov $0x32, %r11d
          0x7f2d12000739: int3 

There seems to be potential to optimize away this assertion, at least for the case of BitAnd with a constant int32 argument.

Might the arguments to the bitwise operations always be int32 values when emitting this code? If so then might the result always be int32 for them?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1079209</commentid>
    <comment_count>1</comment_count>
    <who name="dougc">dtc-llvm</who>
    <bug_when>2015-03-22 19:32:18 -0700</bug_when>
    <thetext>Might be seeing the same on the result of an int32 typed array load. For example:

     473:&lt;!2:loc10&gt;	GetByVal(KnownCell:@450, Int32:@470, @521, JS|MustGen|PureInt|UseAsInt, Int32, Int32ArrayOriginalNonArrayInBoundsAsIs, R:TypedArrayProperties,MiscFields, bc#803)  predicting Int32
          0x7f68c8000e45: mov $0x7f690806fe30, %rcx
          0x7f68c8000e4f: cmp $0x400000, %edx
          0x7f68c8000e55: jae 0x7f68c80012cd
          0x7f68c8000e5b: mov (%rax,%rdx,4), %ebx
          0x7f68c8000e5e: mov $0xffffffff, %r11  ; redundant int32 assertion?
          0x7f68c8000e68: cmp %r11, %rbx
          0x7f68c8000e6b: jbe 0x7f68c8000e78
          0x7f68c8000e71: mov $0x32, %r11d
          0x7f68c8000e77: int3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1079284</commentid>
    <comment_count>2</comment_count>
    <who name="Filip Pizlo">fpizlo</who>
    <bug_when>2015-03-23 08:28:20 -0700</bug_when>
    <thetext>Please try again in release mode.  What you&apos;re seeing is assertions that we inject into the code, when you are in debug mode.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1079462</commentid>
    <comment_count>3</comment_count>
    <who name="dougc">dtc-llvm</who>
    <bug_when>2015-03-23 15:16:58 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Please try again in release mode.  What you&apos;re seeing is assertions that we
&gt; inject into the code, when you are in debug mode.

Yes, these are not emitted in Release code, sorry for the noise.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>