Skip to content

Improve hoisting, CSE, LSRA for MD array accesses #71676

Open

Description

@BruceForstall

As described in the comment #70271 (comment) and those that follow, with change #70271 a regression was introduced in the MDMulMatrix benchmark due to limitations or heuristics in the optimization phases downstream of MD array index expansion.

E.g.,

  • LSRA inserts spills and reloads in unfortunate places, including an identified case of un-spilling and re-spilling in the same block, when the value wasn't modified. One issue to investigate this was opened: Investigate the heuristics for creating DummyDef in LSRA #71539
  • there are many cases where a GT_MDARR_LOWER_BOUND or GT_MDARR_LENGTH node is loop-invariant, but can't be hoisted due to exception ordering, as these could cause null reference exception. This is due to hoisting having a very simple notion of side-effects and ordering. In the identified case, we already know that the specific null reference exception can't occur because a previous expression would have caused it, so we should be free to hoist up to that location.
  • CSE seems to create too many long-lifetime CSE, leading LSRA to spill. For the two mentioned nodes, they are very cheap to compute. If they get assigned a register, it's useful to hoist them, but if they don't, they shouldn't be CSE'ed. Maybe CSE's costing should be improved, or we should implement rematerialization for "undo-ing" some CSE.

category:cq
theme:md-arrays
skill-level:expert
cost:large

impact:medium

Activity

  1. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Jul 5, 2022
  2. added this to the Future milestone on Jul 5, 2022
  3. self-assigned this
    on Jul 5, 2022
  4. modified the milestones: Future, 8.0.0 on Oct 13, 2022
  5. modified the milestones: 8.0.0, 9.0.0 on Jul 7, 2023
  6. modified the milestones: 9.0.0, 10.0.0 on Jul 25, 2024
  7. modified the milestones: 10.0.0, Future on Apr 18, 2025
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

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions