diff options
Diffstat (limited to 'tests/ui/const_prop')
-rw-r--r-- | tests/ui/const_prop/apfloat-f64-roundtrip.rs | 9 | ||||
-rw-r--r-- | tests/ui/const_prop/apfloat-remainder-regression.rs | 15 | ||||
-rw-r--r-- | tests/ui/const_prop/ice-issue-111353.rs | 7 | ||||
-rw-r--r-- | tests/ui/const_prop/ice-issue-96944.rs | 26 |
4 files changed, 57 insertions, 0 deletions
diff --git a/tests/ui/const_prop/apfloat-f64-roundtrip.rs b/tests/ui/const_prop/apfloat-f64-roundtrip.rs new file mode 100644 index 000000000..9fb2ac96b --- /dev/null +++ b/tests/ui/const_prop/apfloat-f64-roundtrip.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags: -O -Zmir-opt-level=3 -Cno-prepopulate-passes +// min-llvm-version: 16.0 (requires APFloat fixes in LLVM) + +// Regression test for a broken MIR optimization (issue #113407). +pub fn main() { + let f = f64::from_bits(0x19873cc2) as f32; + assert_eq!(f.to_bits(), 0); +} diff --git a/tests/ui/const_prop/apfloat-remainder-regression.rs b/tests/ui/const_prop/apfloat-remainder-regression.rs new file mode 100644 index 000000000..08932c333 --- /dev/null +++ b/tests/ui/const_prop/apfloat-remainder-regression.rs @@ -0,0 +1,15 @@ +// run-pass +// compile-flags: -O -Zmir-opt-level=3 -Cno-prepopulate-passes + +// Regression test for a broken MIR optimization (issue #102403). +pub fn f() -> f64 { + std::hint::black_box(-1.0) % std::hint::black_box(-1.0) +} + +pub fn g() -> f64 { + -1.0 % -1.0 +} + +pub fn main() { + assert_eq!(f().signum(), g().signum()); +} diff --git a/tests/ui/const_prop/ice-issue-111353.rs b/tests/ui/const_prop/ice-issue-111353.rs new file mode 100644 index 000000000..99d1b792f --- /dev/null +++ b/tests/ui/const_prop/ice-issue-111353.rs @@ -0,0 +1,7 @@ +// build-pass +#![crate_type = "lib"] +#![feature(unsized_fn_params)] + +pub fn f(mut x: [i32]) { + x[0] = 1; +} diff --git a/tests/ui/const_prop/ice-issue-96944.rs b/tests/ui/const_prop/ice-issue-96944.rs new file mode 100644 index 000000000..74baffddd --- /dev/null +++ b/tests/ui/const_prop/ice-issue-96944.rs @@ -0,0 +1,26 @@ +// build-pass +#![crate_type = "lib"] +#![allow(arithmetic_overflow)] + +pub trait BitSplit { + type Half; + fn merge(halves: [Self::Half; 2]) -> Self; +} + +macro_rules! impl_ints { + ($int:ty => $half:ty; $mask:expr) => { + impl BitSplit for $int { + type Half = $half; + #[inline] + fn merge(halves: [Self::Half; 2]) -> Self { + const HALF_SIZE: usize = std::mem::size_of::<$half>() * 8; + (halves[0] << HALF_SIZE) as $int | halves[1] as $int + } + } + }; +} + +impl_ints!(u128 => u64; 0x0000_0000_0000_0000_FFFF_FFFF_FFFF_FFFF); +impl_ints!( u64 => u32; 0x0000_0000_FFFF_FFFF); +impl_ints!( u32 => u16; 0x0000_FFFF); +impl_ints!( u16 => u8; 0x00FF); |