Skip to content
/ rustc Public
forked from rust-lang/rust
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Trying to promote const local array using GVN pass #5

Closed
wants to merge 13 commits into from

Conversation

tesuji
Copy link
Owner

@tesuji tesuji commented Jun 12, 2024

Rewriting of rust-lang#125916 which used PromoteTemps pass.

Current status

  • commits[1..] doesn't change the test diff.
  • I don't know how to promote local arrays
  • maybe XY problems:
    • I'm trying to return OpTy { op: Indirect(MemPlace { .. }), ty: [i32; 32] } for eval_to_const(array). Because eval_to_const(*&array) is returning a similiar value. That is not enough to promote the array.

// [255, 105, 15, 39, 62, 251, 191, 178, 9, 4, 56, 221],
// [193, 164, 194, 197, 6, 243, 218, 171, 87, 247, 104, 42],
// ];
let _darr = *&[
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns Some(OpTy { op: Indirect(MemPlace { ptr: alloc2<imm>, meta: None, misaligned: None }), ty: [i32; 32] })

// CHECK: let [[array_lit:_.*]]: [i32; 32];
// CHECK: debug _arr => [[arr:_.*]];

let _arr = [
Copy link
Owner Author

@tesuji tesuji Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With commits[3], this now returns as a immutable memplace: Some(OpTy { op: Indirect(MemPlace { ptr: alloc3<imm>, meta: None, misaligned: None }), ty: [i32; 32] }).

But in the mir diff, _arr still is not promoted.

@tesuji tesuji force-pushed the gvn-const-arrays branch from db064ed to 6c0fe34 Compare June 13, 2024 21:42
@tesuji tesuji closed this Jun 13, 2024
tesuji pushed a commit that referenced this pull request Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant