Skip to content

Tracking issue for MIR simplification opportunities #111442

Open
@cjgillot

Description

@cjgillot

This issue is designed to be a list of ideas to simplify MIR during optimization passes. Contributors are welcome to enhance this list.

Note: not all optimizations on this list are desirable. Some are put there to track why they were not implemented.


Instruction simplification

Avoid calling Index::index for slices of arrays and subslices, and replace if with a direct projection:

  • slice[constant1..constant2] to use Subslice { from: constant1, to: constant2, from_end: false};
  • slice[..constant2] to use Subslice { from: 0, to: constant2, from_end: false};
  • slice[constant1..] to use Subslice { from: constant1, to: 0, from_end: true};
  • slice[..] to directly reuse slice;
  • slice[constant1..slice.len() - constant2] to use Subslice { from: constant1, to: constant2, from_end: true};
  • slice[..slice.len() - constant2] to use Subslice { from: 0, to: constant2, from_end: true}.
  • replace manual pointer offset computations with Index projection Tracking issue for MIR simplification opportunities #111442 (comment)

Simple operations:

Aggregates:

Perform simplifications listed in clippy's perf lints #111442 (comment).

Compile-time evaluation

Control-flow graph

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing such

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions