forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#120688 - cjgillot:gvn-partial-move, r=oli-obk GVN: also turn moves into copies with projections Fixes rust-lang#120613
- Loading branch information
Showing
4 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
- // MIR for `fn0` before GVN | ||
+ // MIR for `fn0` after GVN | ||
|
||
fn fn0() -> () { | ||
let mut _0: (); | ||
let mut _1: usize; | ||
let mut _2: [u128; 6]; | ||
let mut _3: ([u128; 6],); | ||
let mut _4: ([u128; 6],); | ||
let mut _5: (); | ||
|
||
bb0: { | ||
_1 = const 1_usize; | ||
_2 = [const 42_u128; 6]; | ||
- _2[_1] = const 1_u128; | ||
+ _2[1 of 2] = const 1_u128; | ||
_3 = (_2,); | ||
_4 = _3; | ||
- _5 = fn1(move (_3.0: [u128; 6]), _4) -> [return: bb1, unwind unreachable]; | ||
+ _5 = fn1((_3.0: [u128; 6]), _3) -> [return: bb1, unwind unreachable]; | ||
} | ||
|
||
bb1: { | ||
return; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// unit-test: GVN | ||
|
||
#![feature(custom_mir, core_intrinsics)] | ||
extern crate core; | ||
use core::intrinsics::mir::*; | ||
|
||
#[custom_mir(dialect = "runtime", phase = "initial")] | ||
fn fn0() { | ||
// CHECK-LABEL: fn fn0( | ||
mir! { | ||
let a: usize; | ||
let b: [u128; 6]; | ||
let c: ([u128; 6],); | ||
let d: ([u128; 6],); | ||
let x: (); | ||
{ | ||
// CHECK: bb0: { | ||
// CHECK-NEXT: _1 = const 1_usize; | ||
// CHECK-NEXT: _2 = [const 42_u128; 6]; | ||
// CHECK-NEXT: _2[1 of 2] = const 1_u128; | ||
// CHECK-NEXT: _3 = (_2,); | ||
// CHECK-NEXT: _4 = _3; | ||
// CHECK-NEXT: _5 = fn1((_3.0: [u128; 6]), _3) | ||
a = 1_usize; | ||
b = [42; 6]; | ||
b[a] = 1; | ||
c = (b,); | ||
d = c; | ||
Call(x = fn1(Move(c.0), d), ReturnTo(bb1), UnwindUnreachable()) | ||
} | ||
bb1 = { | ||
Return() | ||
} | ||
} | ||
} | ||
|
||
#[inline(never)] | ||
fn fn1(a: [u128; 6], mut b: ([u128; 6],)) { | ||
b.0 = [0; 6]; | ||
} | ||
|
||
fn main() { | ||
fn0(); | ||
} | ||
|
||
// EMIT_MIR gvn_copy_moves.fn0.GVN.diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters