Skip to content

Implement machine dependent peephole optimizer at lower time #8035

Open

Description

@russellhadley

New pass is intended to exploit machine dependent instructions and allow for low level optimization based on specific instruction semantics.

Goals:

  • Run before register allocation to remove issues with false dependencies and allow reduction in register pressure.
  • Exploit specific features of the target ISA. Including but not limited to:
    • Immediate encoding size/shift semantics
    • Particular condition flag implementation
    • Target dependent address mode formation
  • Allow more sophisticated instruction selection:
    • bt{s|r|c} formation
    • Aggressive optimization around condition flag/branch sequences.
    • Avoid machine glass jaws like LCP.
  • Reorder/rework instructions to reduce register pressure.

Particular open questions:

  • Which dataflow formulation should be used? Adjacent in window? Expression temp def/use? Unaliased SSA or some cheaper extended basic block approximation?
  • Run just before RA or at higher tier run after?
  • How to encapsulate a transform.
  • How to enforce a high level of debug dump/tracing functionality for managing the transforms.

This is a big and perhaps controversial feature, but is intended to allow for more proactive engagement on code selection opts for collaborators with interests in particular targets.

category:design
theme:optimization
skill-level:expert
cost:extra-large
impact:large

Activity

  1. russellhadley commented on May 9, 2017

    @russellhadley
    ContributorAuthor
  2. mikedn commented on May 10, 2017

    @mikedn
    Contributor

    Add random repro case for bit shifting that we're currently missing on x86.

    Presumably you're referring to the and x, 31 added by the C# compiler. That can be easily be removed in lowering or morph. I once tried in morph, saves ~500 bytes in jitdiff fx.

  3. russellhadley commented on May 10, 2017

    @russellhadley
    ContributorAuthor

    @mikedn If you have the change we'd take it. :) The example was in an old issue in our internal database and I was just cleaning house.

  4. mikedn commented on May 10, 2017

    @mikedn
    Contributor

    @russellhadley The morph version is in dotnet/coreclr#8744. I did it in morph thinking that it may be a good idea to get rid of unnecessary instructions early but then gave up on it because morph is already too hairy. I suppose I'll make a lower version one of these days. After all the example you have is written by me, I just found it on my HDD :)

  5. mikedn commented on May 15, 2017

    @mikedn
    Contributor

    PR for shift count masking removal in lowering: dotnet/coreclr#11594

  6. transferred this issue fromdotnet/coreclron Jan 31, 2020
  7. added this to the Future milestone on Jan 31, 2020
  8. added
    JitUntriaged
    on Oct 28, 2020
  9. removed
    JitUntriaged
    on Nov 24, 2020
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-coreclrenhancementoptimizationtenet-performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions