Skip to content

Const Prop does not finish propagation into user defined variables #66638

New issue

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

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

Already on GitHub? # to your account

Closed
wesleywiser opened this issue Nov 22, 2019 · 0 comments · Fixed by #67130
Closed

Const Prop does not finish propagation into user defined variables #66638

wesleywiser opened this issue Nov 22, 2019 · 0 comments · Fixed by #67130
Assignees
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wesleywiser
Copy link
Member

The const prop pass handles propagation into temporaries correctly but doesn't propagate temporaries into user defined variables.

example

fn main() {
  let x = 2 + 2;
}

currently compiles to the following MIR:

fn  main() -> () {
    let mut _0: ();
    let _1: i32;
    let mut _2: (i32, bool);
    scope 1 {
    }

    bb0: {
        StorageLive(_1);
        (_2.0: i32) = const 4i32;
        (_2.1: bool) = const false;
        _1 = move (_2.0: i32);
        StorageDead(_1);
        return;
    }
}

but should ideally compile to:

fn  main() -> () {
    let mut _0: ();
    let _1: i32;
    scope 1 {
    }

    bb0: {
        StorageLive(_1);
        _1 = const 4i32;
        StorageDead(_1);
        return;
    }
}
@wesleywiser wesleywiser added I-compiletime Issue: Problems and improvements with respect to compile times. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html labels Nov 22, 2019
@wesleywiser wesleywiser self-assigned this Nov 22, 2019
@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 22, 2019
wesleywiser added a commit to wesleywiser/rust that referenced this issue Dec 7, 2019
bors added a commit that referenced this issue Dec 7, 2019
Const prop should finish propagation into user defined variables

Fixes #66638

Temporarily rebased on top of #67015 to get those fixes.

r? @oli-obk
Centril added a commit to Centril/rust that referenced this issue Dec 13, 2019
… r=oli-obk

Const prop should finish propagation into user defined variables

Fixes rust-lang#66638

~~Temporarily rebased on top of rust-lang#67015 to get those fixes.~~

r? @oli-obk
Centril added a commit to Centril/rust that referenced this issue Dec 20, 2019
… r=oli-obk

Const prop should finish propagation into user defined variables

Fixes rust-lang#66638

~~Temporarily rebased on top of rust-lang#67015 to get those fixes.~~

r? @oli-obk
@bors bors closed this as completed in 0745b8c Dec 21, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-enhancement Category: An issue proposing an enhancement or a PR with one. I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants