1
- // skip-filecheck
2
1
// unit-test: InstSimplify
3
2
// compile-flags: -C panic=abort
4
3
@@ -11,6 +10,10 @@ use std::mem::{MaybeUninit, ManuallyDrop, transmute};
11
10
12
11
// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff
13
12
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
+
14
17
// These are nops and should be removed
15
18
let _a = transmute :: < i32 , i32 > ( 1 ) ;
16
19
let _a = transmute :: < Vec < i32 > , Vec < i32 > > ( Vec :: new ( ) ) ;
@@ -19,6 +22,16 @@ pub unsafe fn identity_transmutes() {
19
22
#[ custom_mir( dialect = "runtime" , phase = "initial" ) ]
20
23
// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff
21
24
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
+
22
35
mir ! {
23
36
{
24
37
let A = CastTransmute :: <i32 , u32 >( 1 ) ; // Can be a cast
@@ -33,6 +46,14 @@ pub unsafe fn integer_transmutes() {
33
46
34
47
// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff
35
48
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
+
36
57
let _a: u8 = transmute ( Some ( std:: num:: NonZeroU8 :: MAX ) ) ;
37
58
let _a: i16 = transmute ( std:: num:: Wrapping ( 0_i16 ) ) ;
38
59
let _a: u16 = transmute ( std:: num:: Wrapping ( 0_i16 ) ) ;
0 commit comments