2023-06-08 02:18:34 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: GVN
|
2019-09-14 13:11:31 -05:00
|
|
|
//@ compile-flags: -O
|
|
|
|
|
2023-09-20 16:43:33 -05:00
|
|
|
// EMIT_MIR aggregate.main.GVN.diff
|
2019-09-14 13:11:31 -05:00
|
|
|
fn main() {
|
2023-12-02 14:17:04 -06:00
|
|
|
// CHECK-LABEL: fn main(
|
|
|
|
// CHECK: debug x => [[x:_.*]];
|
|
|
|
// CHECK-NOT: = Add(
|
|
|
|
// CHECK: [[x]] = const 1_u8;
|
|
|
|
// CHECK-NOT: = Add(
|
|
|
|
// CHECK: foo(const 1_u8)
|
2019-09-14 13:11:31 -05:00
|
|
|
let x = (0, 1, 2).1 + 0;
|
2023-01-29 06:50:27 -06:00
|
|
|
foo(x);
|
|
|
|
}
|
|
|
|
|
2023-12-02 14:17:04 -06:00
|
|
|
// Verify that we still propagate if part of the aggregate is not known.
|
2023-09-20 16:43:33 -05:00
|
|
|
// EMIT_MIR aggregate.foo.GVN.diff
|
2023-01-29 06:50:27 -06:00
|
|
|
fn foo(x: u8) {
|
2023-12-02 14:17:04 -06:00
|
|
|
// CHECK-LABEL: fn foo(
|
|
|
|
// CHECK: debug first => [[first:_.*]];
|
|
|
|
// CHECK: debug second => [[second:_.*]];
|
|
|
|
// CHECK-NOT: = Add(
|
|
|
|
// CHECK: [[first]] = const 1_i32;
|
|
|
|
// CHECK-NOT: = Add(
|
|
|
|
// CHECK: [[second]] = const 3_i32;
|
2023-01-29 06:50:27 -06:00
|
|
|
let first = (0, x).0 + 1;
|
|
|
|
let second = (x, 1).1 + 2;
|
2019-09-14 13:11:31 -05:00
|
|
|
}
|