Skip to content

Commit

Permalink
Add tests for #102403 and #113407
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung authored and wesleywiser committed Jul 26, 2023
1 parent 98dd81e commit 9d3e35c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/ui/const_prop/apfloat-f64-roundtrip.rs
Original file line number Diff line number Diff line change
@@ -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);
}
15 changes: 15 additions & 0 deletions tests/ui/const_prop/apfloat-remainder-regression.rs
Original file line number Diff line number Diff line change
@@ -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());
}

0 comments on commit 9d3e35c

Please sign in to comment.