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

couple tweaks to optRemoveRedundantZeroInits #102531

Merged
merged 2 commits into from
May 22, 2024
Merged

Conversation

VSadov
Copy link
Member

@VSadov VSadov commented May 22, 2024

Make the optimizer for GC locals be aware that:

  • CORINFO_HELP_INIT_PINVOKE_FRAME is not a GC safe point (not any more)
  • there are other helpers that are not GC safe points

This removes some unnecessary initializations.

Diffs

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 22, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@VSadov
Copy link
Member Author

VSadov commented May 22, 2024

Example diff:

-15 (-7.54%) : 252648.dasm - (dynamicClass):IL_STUB_PInvoke(byref,byref,byref):int (FullOpts)
@@ -11,9 +11,9 @@
 ;  V01 arg1         [V01,T02] (  4,  4   )   byref  ->  rsi         single-def
 ;  V02 arg2         [V02,T03] (  4,  4   )   byref  ->  rdi         single-def
 ;* V03 loc0         [V03    ] (  0,  0   )     int  ->  zero-ref   
-;  V04 loc1         [V04    ] (  1,  1   )   byref  ->  [rbp-0x40]  must-init pinned single-def
-;  V05 loc2         [V05    ] (  1,  1   )   byref  ->  [rbp-0x48]  must-init pinned single-def
-;  V06 loc3         [V06    ] (  1,  1   )   byref  ->  [rbp-0x50]  must-init pinned single-def
+;  V04 loc1         [V04    ] (  1,  1   )   byref  ->  [rbp-0x40]  pinned single-def
+;  V05 loc2         [V05    ] (  1,  1   )   byref  ->  [rbp-0x48]  pinned single-def
+;  V06 loc3         [V06    ] (  1,  1   )   byref  ->  [rbp-0x50]  pinned single-def
 ;* V07 loc4         [V07    ] (  0,  0   )     int  ->  zero-ref   
 ;* V08 loc5         [V08    ] (  0,  0   )     int  ->  zero-ref   
 ;  V09 OutArgs      [V09    ] (  1,  1   )  struct (32) [rsp+0x00]  do-not-enreg[XS] addr-exposed "OutgoingArgSpace"
@@ -42,10 +42,6 @@ G_M13901_IG01:        ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
        push     rbx
        sub      rsp, 136
        lea      rbp, [rsp+0xC0]
-       vxorps   xmm4, xmm4, xmm4
-       vmovdqa  xmmword ptr [rbp-0x50], xmm4
-       xor      eax, eax
-       mov      qword ptr [rbp-0x40], rax
        mov      rbx, rcx
        ; byrRegs +[rbx]
        mov      rsi, rdx
@@ -53,7 +49,7 @@ G_M13901_IG01:        ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=0000 {}, byref,
        mov      rdi, r8
        ; byrRegs +[rdi]
        mov      r14, r10
-						;; size=54 bbWeight=1 PerfScore 13.33
+						;; size=39 bbWeight=1 PerfScore 9.75
 G_M13901_IG02:        ; bbWeight=1, gcrefRegs=0000 {}, byrefRegs=00C8 {rbx rsi rdi}, byref
        mov      qword ptr [rbp-0x60], r14
        lea      rcx, [rbp-0x98]
@@ -104,7 +100,7 @@ G_M13901_IG06:        ; bbWeight=1, epilog, nogc, extend
        ret      
 						;; size=20 bbWeight=1 PerfScore 5.25
 
-; Total bytes of code 199, prolog size 42, PerfScore 48.08, instruction count 56, allocated bytes for code 199 (MethodHash=7b4bc9b2) for method (dynamicClass):IL_STUB_PInvoke(byref,byref,byref):int (FullOpts)
+; Total bytes of code 184, prolog size 27, PerfScore 44.50, instruction count 52, allocated bytes for code 184 (MethodHash=7b4bc9b2) for method (dynamicClass):IL_STUB_PInvoke(byref,byref,byref):int (FullOpts)

@VSadov VSadov marked this pull request as ready for review May 22, 2024 16:37
@VSadov VSadov requested a review from jakobbotsch May 22, 2024 16:38
@VSadov
Copy link
Member Author

VSadov commented May 22, 2024

CC: @dotnet/jit-contrib

Copy link
Member

@EgorBo EgorBo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>
@VSadov
Copy link
Member Author

VSadov commented May 22, 2024

Thanks!

@VSadov VSadov merged commit 1ee41c6 into dotnet:main May 22, 2024
97 of 107 checks passed
@VSadov VSadov deleted the zeroInitOpt1 branch May 22, 2024 19:49
steveharter pushed a commit to steveharter/runtime that referenced this pull request May 28, 2024
* couple tweaks to optRemoveRedundantZeroInits

* Apply suggestions from code review

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>

---------

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
* couple tweaks to optRemoveRedundantZeroInits

* Apply suggestions from code review

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>

---------

Co-authored-by: Aman Khalid <amankhalid@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants