Fix a corner case in fcvt_to_sint.i32.f64 legalization.

An f64 can represent multiple values in the range INT_MIN-1 < x <=
INT_MIN which all truncate to INT_MIN, so comparing the input value
against INT_MIN is not good enough.

Instead, detect overflow on x <= INT_MIN-1 when INT_MIN-1 is an exact
floating point value.
This commit is contained in:
Jakob Stoklund Olesen
2017-09-28 14:24:39 -07:00
parent 8abcdac5a1
commit 2888ff5bf3
2 changed files with 19 additions and 13 deletions

View File

@@ -6,11 +6,9 @@
//! module in the meta language.
use std::fmt::{self, Display, Formatter};
use std::{i32, u32};
use std::str::FromStr;
#[cfg(test)]
use std::mem;
use std::str::FromStr;
use std::{i32, u32};
/// 64-bit immediate integer operand.
///
@@ -547,7 +545,6 @@ impl Ieee32 {
}
/// Create a new `Ieee32` representing the number `x`.
#[cfg(test)]
pub fn with_float(x: f32) -> Ieee32 {
Ieee32(unsafe { mem::transmute(x) })
}
@@ -600,7 +597,6 @@ impl Ieee64 {
}
/// Create a new `Ieee64` representing the number `x`.
#[cfg(test)]
pub fn with_float(x: f64) -> Ieee64 {
Ieee64(unsafe { mem::transmute(x) })
}