Skip to content

[wasm] [JIT]: Local copy coalescing #136662

Closed

Description

@adamperlin

The following code sequence is from Wasm-compiled System.Private.CoreLib, from
int System.SpanHelpers.IndexOfAny<__Canon>(ref __Canon, __Canon, __Canon, int)

    012A:                       local.get 0
    012C:                       local.get 0
    012E:                       i32.load align=1 offset=12 
    0131:                       local.get 0
    0133:                       i32.load align=1 offset=16
    0136:                       local.get 7
    0138:                       local.set 74
    013A:                       local.get 8
    013C:                       local.set 75
    013E:                       local.get 0
    0140:                       local.get 0
    0142:                       i32.load align=1 offset=12
    0145:                       local.get 74
    0147:                       local.get 75
    0149:                       i32.const 0
    014B:                       call 12914
    014E:                       local.tee 70
    0150:                       local.get 70
    0152:                       i32.load align=1
    0155:                       call_indirect 0 (type 153)

Notice the local.get 7; local.set 74 and local.get 8; local.set 75 at 00136-013C. We move 7 -> 74 and 8 -> 75 only to immediately emit local.get 74; local.get 75 as the arguments for the call at 0155. It would be nice if we could coalesce the moves between locals and instead use local.get 7; local.get 8 directly in cases like these.

Activity

  1. added
    untriaged
    on Oct 29, 2026
  2. added
    arch-wasm
    tenet-performance
    area-CodeGen-coreclr
    and removed
    untriaged
    on Oct 29, 2026
  3. dotnet-policy-service commented on Oct 29, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  4. added this to the 12.0.0 milestone on Oct 29, 2026
  5. dotnet-policy-service commented on Oct 29, 2026

    @dotnet-policy-service
    Contributor

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

  6. pavelsavara commented on Oct 30, 2026

    @pavelsavara
    Member

    Does wasm-opt eliminate it ?

  7. self-assigned this
    on Oct 30, 2026
  8. lewing commented on Oct 30, 2026

    @lewing
    Member

    I'll take a look at a targeted improvement while avoiding big RA changes

  9. lewing commented on Oct 30, 2026

    @lewing
    Member
  10. added a commit that references this issue on Nov 18, 2026
    19736f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-CodeGen-coreclrtenet-performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions