Skip to content

Commit 68c409f

Browse files
committed
FileCheck combine_transmutes.
1 parent 386fff3 commit 68c409f

4 files changed

+22
-1
lines changed

tests/mir-opt/combine_transmutes.rs renamed to tests/mir-opt/instsimplify/combine_transmutes.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// unit-test: InstSimplify
32
// compile-flags: -C panic=abort
43

@@ -11,6 +10,10 @@ use std::mem::{MaybeUninit, ManuallyDrop, transmute};
1110

1211
// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff
1312
pub unsafe fn identity_transmutes() {
13+
// CHECK-LABEL: fn identity_transmutes(
14+
// CHECK-NOT: as i32 (Transmute);
15+
// CHECK-NOT: as Vec<i32> (Transmute);
16+
1417
// These are nops and should be removed
1518
let _a = transmute::<i32, i32>(1);
1619
let _a = transmute::<Vec<i32>, Vec<i32>>(Vec::new());
@@ -19,6 +22,16 @@ pub unsafe fn identity_transmutes() {
1922
#[custom_mir(dialect = "runtime", phase = "initial")]
2023
// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff
2124
pub unsafe fn integer_transmutes() {
25+
// CHECK-LABEL: fn integer_transmutes(
26+
// CHECK-NOT: _i32 as u32 (Transmute);
27+
// CHECK: _i32 as u32 (IntToInt);
28+
// CHECK: _i32 as i64 (Transmute);
29+
// CHECK-NOT: _u64 as i64 (Transmute);
30+
// CHECK: _u64 as i64 (IntToInt);
31+
// CHECK: _u64 as u32 (Transmute);
32+
// CHECK-NOT: _isize as usize (Transmute);
33+
// CHECK: _isize as usize (IntToInt);
34+
2235
mir! {
2336
{
2437
let A = CastTransmute::<i32, u32>(1); // Can be a cast
@@ -33,6 +46,14 @@ pub unsafe fn integer_transmutes() {
3346

3447
// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff
3548
pub unsafe fn adt_transmutes() {
49+
// CHECK-LABEL: fn adt_transmutes(
50+
// CHECK: as u8 (Transmute);
51+
// CHECK: ({{_.*}}.0: i16);
52+
// CHECK: as u16 (Transmute);
53+
// CHECK: as u32 (Transmute);
54+
// CHECK: as i32 (Transmute);
55+
// CHECK: ({{_.*}}.1: std::mem::ManuallyDrop<std::string::String>);
56+
3657
let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX));
3758
let _a: i16 = transmute(std::num::Wrapping(0_i16));
3859
let _a: u16 = transmute(std::num::Wrapping(0_i16));

0 commit comments

Comments
 (0)