rust/tests/mir-opt/instsimplify/combine_transmutes.keep_transparent_transmute.InstSimplify-after-simplifycfg.diff
Scott McMurray 8dcc676c92 [mir-opt] GVN some more transmute cases
We already did `Transmute`-then-`PtrToPtr`; this adds the nearly-identical `PtrToPtr`-then-`Transmute`.

It also adds `transmute(Foo(x))` → `transmute(x)`, when `Foo` is a single-field transparent type.  That's useful for things like `NonNull { pointer: p }.as_ptr()`.

Found these as I was looking at MCP807-related changes.
2025-01-08 18:46:30 -08:00

31 lines
829 B
Diff

- // MIR for `keep_transparent_transmute` before InstSimplify-after-simplifycfg
+ // MIR for `keep_transparent_transmute` after InstSimplify-after-simplifycfg
fn keep_transparent_transmute() -> () {
let mut _0: ();
let _1: i16;
let mut _3: std::num::Wrapping<i16>;
scope 1 {
debug _a => _1;
let _2: i16;
scope 2 {
debug _a => _2;
}
}
bb0: {
StorageLive(_1);
_1 = const keep_transparent_transmute::{constant#0} as i16 (Transmute);
StorageLive(_2);
StorageLive(_3);
_3 = Wrapping::<i16>(const 0_i16);
_2 = move _3 as i16 (Transmute);
StorageDead(_3);
_0 = const ();
StorageDead(_2);
StorageDead(_1);
return;
}
}