FileCheck combine_transmutes.
This commit is contained in:
parent
386fff34f7
commit
68c409f8f6
@ -1,4 +1,3 @@
|
|||||||
// skip-filecheck
|
|
||||||
// unit-test: InstSimplify
|
// unit-test: InstSimplify
|
||||||
// compile-flags: -C panic=abort
|
// compile-flags: -C panic=abort
|
||||||
|
|
||||||
@ -11,6 +10,10 @@
|
|||||||
|
|
||||||
// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff
|
// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff
|
||||||
pub unsafe fn identity_transmutes() {
|
pub unsafe fn identity_transmutes() {
|
||||||
|
// CHECK-LABEL: fn identity_transmutes(
|
||||||
|
// CHECK-NOT: as i32 (Transmute);
|
||||||
|
// CHECK-NOT: as Vec<i32> (Transmute);
|
||||||
|
|
||||||
// These are nops and should be removed
|
// These are nops and should be removed
|
||||||
let _a = transmute::<i32, i32>(1);
|
let _a = transmute::<i32, i32>(1);
|
||||||
let _a = transmute::<Vec<i32>, Vec<i32>>(Vec::new());
|
let _a = transmute::<Vec<i32>, Vec<i32>>(Vec::new());
|
||||||
@ -19,6 +22,16 @@ pub unsafe fn identity_transmutes() {
|
|||||||
#[custom_mir(dialect = "runtime", phase = "initial")]
|
#[custom_mir(dialect = "runtime", phase = "initial")]
|
||||||
// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff
|
// EMIT_MIR combine_transmutes.integer_transmutes.InstSimplify.diff
|
||||||
pub unsafe fn integer_transmutes() {
|
pub unsafe fn integer_transmutes() {
|
||||||
|
// CHECK-LABEL: fn integer_transmutes(
|
||||||
|
// CHECK-NOT: _i32 as u32 (Transmute);
|
||||||
|
// CHECK: _i32 as u32 (IntToInt);
|
||||||
|
// CHECK: _i32 as i64 (Transmute);
|
||||||
|
// CHECK-NOT: _u64 as i64 (Transmute);
|
||||||
|
// CHECK: _u64 as i64 (IntToInt);
|
||||||
|
// CHECK: _u64 as u32 (Transmute);
|
||||||
|
// CHECK-NOT: _isize as usize (Transmute);
|
||||||
|
// CHECK: _isize as usize (IntToInt);
|
||||||
|
|
||||||
mir! {
|
mir! {
|
||||||
{
|
{
|
||||||
let A = CastTransmute::<i32, u32>(1); // Can be a cast
|
let A = CastTransmute::<i32, u32>(1); // Can be a cast
|
||||||
@ -33,6 +46,14 @@ pub unsafe fn integer_transmutes() {
|
|||||||
|
|
||||||
// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff
|
// EMIT_MIR combine_transmutes.adt_transmutes.InstSimplify.diff
|
||||||
pub unsafe fn adt_transmutes() {
|
pub unsafe fn adt_transmutes() {
|
||||||
|
// CHECK-LABEL: fn adt_transmutes(
|
||||||
|
// CHECK: as u8 (Transmute);
|
||||||
|
// CHECK: ({{_.*}}.0: i16);
|
||||||
|
// CHECK: as u16 (Transmute);
|
||||||
|
// CHECK: as u32 (Transmute);
|
||||||
|
// CHECK: as i32 (Transmute);
|
||||||
|
// CHECK: ({{_.*}}.1: std::mem::ManuallyDrop<std::string::String>);
|
||||||
|
|
||||||
let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX));
|
let _a: u8 = transmute(Some(std::num::NonZeroU8::MAX));
|
||||||
let _a: i16 = transmute(std::num::Wrapping(0_i16));
|
let _a: i16 = transmute(std::num::Wrapping(0_i16));
|
||||||
let _a: u16 = transmute(std::num::Wrapping(0_i16));
|
let _a: u16 = transmute(std::num::Wrapping(0_i16));
|
Loading…
Reference in New Issue
Block a user