Skip to content

ARM64: Optimize pair of "str wzr, [reg]" to "str xzr" #35136

Description

@kunalspathak
str     wzr, [x1,#8]
str     wzr, [x1,#12]

can be combined into str xzr if the stores are happening in subsequent memory.

str     xzr, [x1,#8]

I collected no. of such str pairs in framework libraries and found approx. 450 pairs in 353 methods.

Details:

str_str_wzr_to_str_xzr.txt

category:cq
theme:optimization
skill-level:intermediate
cost:small
impact:medium

Activity

  1. Dotnet-GitSync-Bot commented on Apr 17, 2020

    @Dotnet-GitSync-Bot
    Collaborator

    I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label.

  2. BruceForstall commented on Apr 18, 2020

    @BruceForstall
    Contributor

    In addition, a sequence of 4 str wzr could be collapsed down to a single stp xzr, xzr by further optimizing using #35134.

  3. BruceForstall commented on Apr 18, 2020

    @BruceForstall
    Contributor

    In the attached file, there are some interesting example that are more complicated than simple adjacency peephole optimization. E.g.,

    ; Assembly listing for method System.Data.ExpressionParser:StartScan():this
    [0024]        B9003C1F          str     wzr, [x0,#60]
    [0025]        B900301F          str     wzr, [x0,#48]
    [0026]        B900341F          str     wzr, [x0,#52]
    [0027]        B900401F          str     wzr, [x0,#64]
    

    Could be:

    str     xzr, [x0,#48]
    str     xzr, [x0,#60]
    

    but it require recognizing that the non-contiguous offsets 60 and 64 can be combined.

  4. added this to the Future milestone on Apr 20, 2020
  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Apr 20, 2020
  6. modified the milestones: Future, 6.0.0 on Nov 9, 2020
  7. modified the milestones: 6.0.0, Future on Mar 23, 2021
  8. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Apr 5, 2023
  9. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Apr 6, 2023
  10. ghost locked as resolved and limited conversation to collaborators on May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-arm64area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions