mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Add a GVN test for 127089 that doesn't optimize to a constant
This commit is contained in:
parent
c9f36f8cd7
commit
f6942112eb
@ -0,0 +1,16 @@
|
||||
- // MIR for `remove_casts_must_change_both_sides` before GVN
|
||||
+ // MIR for `remove_casts_must_change_both_sides` after GVN
|
||||
|
||||
fn remove_casts_must_change_both_sides(_1: &*mut u8, _2: *mut u8) -> bool {
|
||||
let mut _0: bool;
|
||||
let mut _3: *const u8;
|
||||
let mut _4: *const u8;
|
||||
|
||||
bb0: {
|
||||
_3 = (*_1) as *const u8 (PtrToPtr);
|
||||
_4 = _2 as *const u8 (PtrToPtr);
|
||||
_0 = Eq(_3, _4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
- // MIR for `remove_casts_must_change_both_sides` before GVN
|
||||
+ // MIR for `remove_casts_must_change_both_sides` after GVN
|
||||
|
||||
fn remove_casts_must_change_both_sides(_1: &*mut u8, _2: *mut u8) -> bool {
|
||||
let mut _0: bool;
|
||||
let mut _3: *const u8;
|
||||
let mut _4: *const u8;
|
||||
|
||||
bb0: {
|
||||
_3 = (*_1) as *const u8 (PtrToPtr);
|
||||
_4 = _2 as *const u8 (PtrToPtr);
|
||||
_0 = Eq(_3, _4);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -926,6 +926,25 @@ unsafe fn cast_pointer_then_transmute(thin: *mut u32, fat: *mut [u8]) {
|
||||
let fat_addr: usize = std::intrinsics::transmute(fat as *const ());
|
||||
}
|
||||
|
||||
#[custom_mir(dialect = "analysis")]
|
||||
fn remove_casts_must_change_both_sides(mut_a: &*mut u8, mut_b: *mut u8) -> bool {
|
||||
// CHECK-LABEL: fn remove_casts_must_change_both_sides(
|
||||
mir! {
|
||||
// We'd like to remove these casts, but we can't change *both* of them
|
||||
// to be locals, so make sure we don't change one without the other, as
|
||||
// that would be a type error.
|
||||
{
|
||||
// CHECK: [[A:_.+]] = (*_1) as *const u8 (PtrToPtr);
|
||||
let a = *mut_a as *const u8;
|
||||
// CHECK: [[B:_.+]] = _2 as *const u8 (PtrToPtr);
|
||||
let b = mut_b as *const u8;
|
||||
// CHECK: _0 = Eq([[A]], [[B]]);
|
||||
RET = a == b;
|
||||
Return()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
subexpression_elimination(2, 4, 5);
|
||||
wrap_unwrap(5);
|
||||
@ -995,3 +1014,4 @@ fn identity<T>(x: T) -> T {
|
||||
// EMIT_MIR gvn.generic_cast_metadata.GVN.diff
|
||||
// EMIT_MIR gvn.cast_pointer_eq.GVN.diff
|
||||
// EMIT_MIR gvn.cast_pointer_then_transmute.GVN.diff
|
||||
// EMIT_MIR gvn.remove_casts_must_change_both_sides.GVN.diff
|
||||
|
Loading…
Reference in New Issue
Block a user