Skip to content

See through aggregates in GVN#116270

Merged
bors merged 28 commits intorust-lang:masterfrom
cjgillot:gvn-aggregate
Oct 29, 2023
Merged

See through aggregates in GVN#116270
bors merged 28 commits intorust-lang:masterfrom
cjgillot:gvn-aggregate

Conversation

@cjgillot
Copy link
Copy Markdown
Contributor

@cjgillot cjgillot commented Sep 29, 2023

This PR is extracted from #111344

The first 2 commit are cleanups to avoid repeated work. I propose to stop removing useless assignments as part of this pass, and let a later SimplifyLocals do it. This makes tests easier to read (among others).

The next 3 commits add a constant folding mechanism to the GVN pass, presented in #116012. This pass is designed to only use global allocations, to avoid any risk of accidental modification of the stored state.

The following commits implement opportunistic simplifications, in particular:

  • projections of aggregates: MyStruct { x: a }.x gets replaced by a, works with enums too;
  • projections of arrays: [a, b][0] becomes a;
  • projections of repeat expressions: [a; N][x] becomes a;
  • transform arrays of equal operands into a repeat rvalue.

Fixes rust-lang/miri#3090

r? @oli-obk

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mir-opt Area: MIR optimizations merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-enable fn ptr inequality test

9 participants