Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JitDiff X64] [xtqqczze] Avoid OverflowException in Boolean.TryFormat #689

Open
MihuBot opened this issue Oct 5, 2024 · 2 comments
Open

Comments

@MihuBot
Copy link
Owner

MihuBot commented Oct 5, 2024

Job completed in 18 minutes 33 seconds.
dotnet/runtime#108572

Diffs

Found 263 files with textual diffs.

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 39447446
Total bytes of diff: 39447394
Total bytes of delta: -52 (-0.00 % of base)
Total relative delta: -0.36
    diff is an improvement.
    relative diff is an improvement.


Top file improvements (bytes):
         -44 : System.Private.CoreLib.dasm (-0.00 % of base)
          -8 : System.Net.HttpListener.dasm (-0.01 % of base)

2 total files with Code Size differences (2 improved, 0 regressed), 257 unchanged.

Top method improvements (bytes):
         -44 (-34.65 % of base) : System.Private.CoreLib.dasm - System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
          -8 (-1.01 % of base) : System.Net.HttpListener.dasm - System.Net.HttpConnection:.ctor(System.Net.Sockets.Socket,System.Net.HttpEndPointListener,ubyte,System.Security.Cryptography.X509Certificates.X509Certificate):this (FullOpts)

Top method improvements (percentages):
         -44 (-34.65 % of base) : System.Private.CoreLib.dasm - System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
          -8 (-1.01 % of base) : System.Net.HttpListener.dasm - System.Net.HttpConnection:.ctor(System.Net.Sockets.Socket,System.Net.HttpEndPointListener,ubyte,System.Security.Cryptography.X509Certificates.X509Certificate):this (FullOpts)

2 total methods with Code Size differences (2 improved, 0 regressed), 232538 unchanged.

--------------------------------------------------------------------------------

Artifacts:

@MihuBot
Copy link
Owner Author

MihuBot commented Oct 5, 2024

Top method improvements

-44 (-34.65 % of base) - System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this
 ; Assembly listing for method System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
 ; Emitting BLENDED_CODE for X64 with AVX - Unix
 ; FullOpts code
 ; optimized code
 ; rbp based frame
 ; partially interruptible
 ; No PGO data
-; 0 inlinees with PGO data; 6 single block inlinees; 4 inlinees without PGO data
+; 0 inlinees with PGO data; 2 single block inlinees; 0 inlinees without PGO data
 ; Final local variable assignments
 ;
-;  V00 this         [V00,T02] (  3,  3   )   byref  ->  rdi         this single-def
+;  V00 this         [V00,T01] (  3,  3   )   byref  ->  rdi         this single-def
 ;* V01 arg1         [V01    ] (  0,  0   )  struct (16) zero-ref    multireg-arg ld-addr-op single-def <System.Span`1[ushort]>
 ;  V02 arg2         [V02,T00] (  5,  3.50)   byref  ->  rcx         single-def
-;* V03 loc0         [V03    ] (  0,  0   )    long  ->  zero-ref    ld-addr-op
-;* V04 loc1         [V04    ] (  0,  0   )    long  ->  zero-ref    ld-addr-op
+;* V03 loc0         [V03    ] (  0,  0   )    long  ->  zero-ref   
+;* V04 loc1         [V04    ] (  0,  0   )    long  ->  zero-ref   
 ;# V05 OutArgs      [V05    ] (  1,  1   )  struct ( 0) [rsp+0x00]  do-not-enreg[XS] addr-exposed "OutgoingArgSpace"
-;* V06 tmp1         [V06    ] (  0,  0   )  struct (16) zero-ref    "spilled call-like call argument" <System.Span`1[ubyte]>
-;* V07 tmp2         [V07    ] (  0,  0   )  struct (16) zero-ref    "spilled call-like call argument" <System.Span`1[ubyte]>
-;* V08 tmp3         [V08    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ushort]>
-;* V09 tmp4         [V09    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "NewObj constructor temp" <System.Span`1[ubyte]>
-;* V10 tmp5         [V10    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ushort]>
-;* V11 tmp6         [V11    ] (  0,  0   )   byref  ->  zero-ref    single-def "Inlining Arg"
-;  V12 tmp7         [V12,T04] (  2,  2   )     int  ->  rax         "Inlining Arg"
-;* V13 tmp8         [V13    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ubyte]>
-;* V14 tmp9         [V14    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ubyte]>
-;* V15 tmp10        [V15    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ushort]>
-;* V16 tmp11        [V16    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "NewObj constructor temp" <System.Span`1[ubyte]>
-;* V17 tmp12        [V17    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ushort]>
-;* V18 tmp13        [V18    ] (  0,  0   )   byref  ->  zero-ref    single-def "Inlining Arg"
-;  V19 tmp14        [V19,T05] (  2,  2   )     int  ->  rax         "Inlining Arg"
-;* V20 tmp15        [V20    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ubyte]>
-;* V21 tmp16        [V21    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ubyte]>
-;  V22 tmp17        [V22,T03] (  4,  2.50)   byref  ->  rsi         single-def "field V01._reference (fldOffset=0x0)" P-INDEP
-;  V23 tmp18        [V23,T01] (  5,  3   )     int  ->  rdx         single-def "field V01._length (fldOffset=0x8)" P-INDEP
-;* V24 tmp19        [V24    ] (  0,  0   )   byref  ->  zero-ref    "field V06._reference (fldOffset=0x0)" P-INDEP
-;* V25 tmp20        [V25    ] (  0,  0   )     int  ->  zero-ref    "field V06._length (fldOffset=0x8)" P-INDEP
-;* V26 tmp21        [V26    ] (  0,  0   )   byref  ->  zero-ref    "field V07._reference (fldOffset=0x0)" P-INDEP
-;* V27 tmp22        [V27    ] (  0,  0   )     int  ->  zero-ref    "field V07._length (fldOffset=0x8)" P-INDEP
-;* V28 tmp23        [V28    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V08._reference (fldOffset=0x0)" P-INDEP
-;* V29 tmp24        [V29    ] (  0,  0   )     int  ->  zero-ref    "field V08._length (fldOffset=0x8)" P-INDEP
-;* V30 tmp25        [V30    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V09._reference (fldOffset=0x0)" P-INDEP
-;* V31 tmp26        [V31    ] (  0,  0   )     int  ->  zero-ref    "field V09._length (fldOffset=0x8)" P-INDEP
-;* V32 tmp27        [V32    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V10._reference (fldOffset=0x0)" P-INDEP
-;* V33 tmp28        [V33    ] (  0,  0   )     int  ->  zero-ref    "field V10._length (fldOffset=0x8)" P-INDEP
-;* V34 tmp29        [V34    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V13._reference (fldOffset=0x0)" P-INDEP
-;* V35 tmp30        [V35    ] (  0,  0   )     int  ->  zero-ref    "field V13._length (fldOffset=0x8)" P-INDEP
-;* V36 tmp31        [V36    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V14._reference (fldOffset=0x0)" P-INDEP
-;* V37 tmp32        [V37    ] (  0,  0   )     int  ->  zero-ref    "field V14._length (fldOffset=0x8)" P-INDEP
-;* V38 tmp33        [V38    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V15._reference (fldOffset=0x0)" P-INDEP
-;* V39 tmp34        [V39    ] (  0,  0   )     int  ->  zero-ref    "field V15._length (fldOffset=0x8)" P-INDEP
-;* V40 tmp35        [V40    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V16._reference (fldOffset=0x0)" P-INDEP
-;* V41 tmp36        [V41    ] (  0,  0   )     int  ->  zero-ref    "field V16._length (fldOffset=0x8)" P-INDEP
-;* V42 tmp37        [V42    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V17._reference (fldOffset=0x0)" P-INDEP
-;* V43 tmp38        [V43    ] (  0,  0   )     int  ->  zero-ref    "field V17._length (fldOffset=0x8)" P-INDEP
-;* V44 tmp39        [V44    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V20._reference (fldOffset=0x0)" P-INDEP
-;* V45 tmp40        [V45    ] (  0,  0   )     int  ->  zero-ref    "field V20._length (fldOffset=0x8)" P-INDEP
-;* V46 tmp41        [V46    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V21._reference (fldOffset=0x0)" P-INDEP
-;* V47 tmp42        [V47    ] (  0,  0   )     int  ->  zero-ref    "field V21._length (fldOffset=0x8)" P-INDEP
+;* V06 tmp1         [V06    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ushort]>
+;* V07 tmp2         [V07    ] (  0,  0   )  struct (16) zero-ref    ld-addr-op "Inlining Arg" <System.Span`1[ushort]>
+;  V08 tmp3         [V08,T02] (  4,  2.50)   byref  ->  rsi         single-def "field V01._reference (fldOffset=0x0)" P-INDEP
+;  V09 tmp4         [V09,T03] (  3,  2   )     int  ->  rdx         single-def "field V01._length (fldOffset=0x8)" P-INDEP
+;* V10 tmp5         [V10    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V06._reference (fldOffset=0x0)" P-INDEP
+;* V11 tmp6         [V11    ] (  0,  0   )     int  ->  zero-ref    "field V06._length (fldOffset=0x8)" P-INDEP
+;* V12 tmp7         [V12    ] (  0,  0   )   byref  ->  zero-ref    single-def "field V07._reference (fldOffset=0x0)" P-INDEP
+;* V13 tmp8         [V13    ] (  0,  0   )     int  ->  zero-ref    "field V07._length (fldOffset=0x8)" P-INDEP
 ;
 ; Lcl frame size = 0
 
 G_M62266_IG01:
        push     rbp
        mov      rbp, rsp
 						;; size=4 bbWeight=1 PerfScore 1.25
 G_M62266_IG02:
        cmp      byte  ptr [rdi], 0
        jne      SHORT G_M62266_IG05
 						;; size=5 bbWeight=1 PerfScore 4.00
 G_M62266_IG03:
-       cmp      edx, 4
-       jle      SHORT G_M62266_IG06
-       imul     eax, edx, 2
-       jo       SHORT G_M62266_IG11
-       cmp      eax, 8
-       jb       SHORT G_M62266_IG10
+       cmp      edx, 5
+       jl       SHORT G_M62266_IG06
        mov      rax, 0xD1FFAB1E
        mov      qword ptr [rsi], rax
        mov      word  ptr [rsi+0x08], 101
        mov      dword ptr [rcx], 5
        mov      eax, 1
-						;; size=45 bbWeight=0.50 PerfScore 4.50
+						;; size=35 bbWeight=0.50 PerfScore 2.38
 G_M62266_IG04:
        pop      rbp
        ret      
 						;; size=2 bbWeight=0.50 PerfScore 0.75
 G_M62266_IG05:
-       cmp      edx, 3
-       jg       SHORT G_M62266_IG08
+       cmp      edx, 4
+       jge      SHORT G_M62266_IG08
 						;; size=5 bbWeight=0.50 PerfScore 0.62
 G_M62266_IG06:
        xor      eax, eax
        mov      dword ptr [rcx], eax
 						;; size=4 bbWeight=0.50 PerfScore 0.62
 G_M62266_IG07:
        pop      rbp
        ret      
 						;; size=2 bbWeight=0.50 PerfScore 0.75
 G_M62266_IG08:
-       imul     eax, edx, 2
-       jo       SHORT G_M62266_IG11
-       cmp      eax, 8
-       jb       SHORT G_M62266_IG10
        mov      rax, 0xD1FFAB1E
        mov      qword ptr [rsi], rax
        mov      dword ptr [rcx], 4
        mov      eax, 1
-						;; size=34 bbWeight=0.50 PerfScore 3.38
+						;; size=24 bbWeight=0.50 PerfScore 1.25
 G_M62266_IG09:
        pop      rbp
        ret      
 						;; size=2 bbWeight=0.50 PerfScore 0.75
-G_M62266_IG10:
-       mov      edi, 40
-       mov      rax, 0xD1FFAB1E      ; code for System.ThrowHelper:ThrowArgumentOutOfRangeException(int)
-       call     [rax]System.ThrowHelper:ThrowArgumentOutOfRangeException(int)
-       int3     
-						;; size=18 bbWeight=0 PerfScore 0.00
-G_M62266_IG11:
-       call     CORINFO_HELP_OVERFLOW
-       int3     
-						;; size=6 bbWeight=0 PerfScore 0.00
 
-; Total bytes of code 127, prolog size 4, PerfScore 16.62, instruction count 39, allocated bytes for code 127 (MethodHash=7f390cc5) for method System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
+; Total bytes of code 83, prolog size 4, PerfScore 12.38, instruction count 25, allocated bytes for code 83 (MethodHash=7f390cc5) for method System.Boolean:TryFormat(System.Span`1[ushort],byref):ubyte:this (FullOpts)
 ; ============================================================

Note: some changes were skipped as they were likely noise.

@MihuBot
Copy link
Owner Author

MihuBot commented Oct 5, 2024

@xtqqczze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant