File: gvn_copy_moves.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (46 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//@ test-mir-pass: 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 = (copy _2,);
            // CHECK-NEXT: _4 = copy _3;
            // CHECK-NEXT: _5 = fn1(copy (_3.0: [u128; 6]), copy _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