Skip to content

[RyuJIT][LSRA] Take register encoding sizes into account #7996

Closed

Description

@CarolEidt

Consider preferring smaller encoding sizes for high ref count, and larger encoding sizes for small ref count.
(This issue was migrated from the desktop bug tracking system.)
category:cq
theme:register-allocator
skill-level:expert
cost:medium

Activity

  1. mikedn commented on Jan 29, 2018

    @mikedn
    Contributor

    A related example I happened to stumble upon:

    class Num { public int x, y, z, w; }
    static Dictionary<int, Num> Test(int x, int y)
    {
        return new Dictionary<int, Num> { { 42, new Num { x = x, y = y, z = 4, w = 2 } } };
    }

    generates:

    E8C78B815F           call     CORINFO_HELP_NEWSFAST
    4C8BC0               mov      r8, rax
    41897008             mov      dword ptr [r8+8], esi
    4189780C             mov      dword ptr [r8+12], edi
    41C7401004000000     mov      dword ptr [r8+16], 4
    41C7401402000000     mov      dword ptr [r8+20], 2
    488BCB               mov      rcx, rbx
    BA2A000000           mov      edx, 42
    41B902000000         mov      r9d, 2
    E84969A35E           call     System.Collections.Generic.Dictionary`2[Int32,__Canon][System.Int32,System.__Canon]:TryInsert(int,ref,ubyte):bool:this

    Here LSRA was too eager to move to r8 (presumably selected due to ABI requirements). If the move to r8 was delayed until the actual call the code would have been 4 bytes smaller.

  2. transferred this issue fromdotnet/coreclron Jan 31, 2020
  3. added this to the Future milestone on Jan 31, 2020
  4. modified the milestones: Future, 6.0.0 on Oct 27, 2020
  5. added
    needs-further-triage
    on Mar 23, 2021
  6. removed
    needs-further-triage
    on Apr 9, 2021
  7. modified the milestones: 6.0.0, Future on Apr 9, 2021
  8. kunalspathak commented on Apr 9, 2021

    @kunalspathak
    Contributor

    I do not think we will have time to do this in .NET 6.

  9. kunalspathak commented on Sep 23, 2023

    @kunalspathak
    Contributor

    Fixed by #88151

  10. kunalspathak commented on Sep 23, 2023

    @kunalspathak
    Contributor

    Latest assembly code for the example in #7996 (comment):

           call     CORINFO_HELP_NEWSFAST
           mov      dword ptr [rax+08H], esi
           mov      dword ptr [rax+0CH], edi
           mov      dword ptr [rax+10H], 4
           mov      dword ptr [rax+14H], 2
           mov      rcx, rbx
           mov      r8, rax
           mov      edx, 42
           mov      r9d, 2
    
  11. ghost locked as resolved and limited conversation to collaborators on Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrenhancementoptimizationtenet-performance

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions