about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/miri/src/shims/x86/avx.rs5
-rw-r--r--src/tools/miri/src/shims/x86/mod.rs20
-rw-r--r--src/tools/miri/src/shims/x86/sse.rs17
-rw-r--r--src/tools/miri/src/shims/x86/sse2.rs40
-rw-r--r--src/tools/miri/tests/fail/intrinsics/intrinsic_target_feature.rs6
5 files changed, 11 insertions, 77 deletions
diff --git a/src/tools/miri/src/shims/x86/avx.rs b/src/tools/miri/src/shims/x86/avx.rs
index f36bb4826e4..2f6569e1823 100644
--- a/src/tools/miri/src/shims/x86/avx.rs
+++ b/src/tools/miri/src/shims/x86/avx.rs
@@ -73,13 +73,12 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
 
                 round_all::<rustc_apfloat::ieee::Double>(this, op, rounding, dest)?;
             }
-            // Used to implement _mm256_{sqrt,rcp,rsqrt}_ps functions.
+            // Used to implement _mm256_{rcp,rsqrt}_ps functions.
             // Performs the operations on all components of `op`.
-            "sqrt.ps.256" | "rcp.ps.256" | "rsqrt.ps.256" => {
+            "rcp.ps.256" | "rsqrt.ps.256" => {
                 let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
 
                 let which = match unprefixed_name {
-                    "sqrt.ps.256" => FloatUnaryOp::Sqrt,
                     "rcp.ps.256" => FloatUnaryOp::Rcp,
                     "rsqrt.ps.256" => FloatUnaryOp::Rsqrt,
                     _ => unreachable!(),
diff --git a/src/tools/miri/src/shims/x86/mod.rs b/src/tools/miri/src/shims/x86/mod.rs
index 1bd32fce8bd..c1117e4d811 100644
--- a/src/tools/miri/src/shims/x86/mod.rs
+++ b/src/tools/miri/src/shims/x86/mod.rs
@@ -159,8 +159,6 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
 
 #[derive(Copy, Clone)]
 enum FloatBinOp {
-    /// Arithmetic operation
-    Arith(mir::BinOp),
     /// Comparison
     ///
     /// The semantics of this operator is a case distinction: we compare the two operands,
@@ -247,16 +245,11 @@ impl FloatBinOp {
 /// Performs `which` scalar operation on `left` and `right` and returns
 /// the result.
 fn bin_op_float<'tcx, F: rustc_apfloat::Float>(
-    this: &crate::MiriInterpCx<'tcx>,
     which: FloatBinOp,
     left: &ImmTy<'tcx>,
     right: &ImmTy<'tcx>,
 ) -> InterpResult<'tcx, Scalar> {
     match which {
-        FloatBinOp::Arith(which) => {
-            let res = this.binary_op(which, left, right)?;
-            Ok(res.to_scalar())
-        }
         FloatBinOp::Cmp { gt, lt, eq, unord } => {
             let left = left.to_scalar().to_float::<F>()?;
             let right = right.to_scalar().to_float::<F>()?;
@@ -323,7 +316,6 @@ fn bin_op_simd_float_first<'tcx, F: rustc_apfloat::Float>(
     assert_eq!(dest_len, right_len);
 
     let res0 = bin_op_float::<F>(
-        this,
         which,
         &this.read_immediate(&this.project_index(&left, 0)?)?,
         &this.read_immediate(&this.project_index(&right, 0)?)?,
@@ -358,7 +350,7 @@ fn bin_op_simd_float_all<'tcx, F: rustc_apfloat::Float>(
         let right = this.read_immediate(&this.project_index(&right, i)?)?;
         let dest = this.project_index(&dest, i)?;
 
-        let res = bin_op_float::<F>(this, which, &left, &right)?;
+        let res = bin_op_float::<F>(which, &left, &right)?;
         this.write_scalar(res, &dest)?;
     }
 
@@ -367,11 +359,6 @@ fn bin_op_simd_float_all<'tcx, F: rustc_apfloat::Float>(
 
 #[derive(Copy, Clone)]
 enum FloatUnaryOp {
-    /// sqrt(x)
-    ///
-    /// <https://www.felixcloutier.com/x86/sqrtss>
-    /// <https://www.felixcloutier.com/x86/sqrtps>
-    Sqrt,
     /// Approximation of 1/x
     ///
     /// <https://www.felixcloutier.com/x86/rcpss>
@@ -392,11 +379,6 @@ fn unary_op_f32<'tcx>(
     op: &ImmTy<'tcx>,
 ) -> InterpResult<'tcx, Scalar> {
     match which {
-        FloatUnaryOp::Sqrt => {
-            let op = op.to_scalar();
-            // FIXME using host floats
-            Ok(Scalar::from_u32(f32::from_bits(op.to_u32()?).sqrt().to_bits()))
-        }
         FloatUnaryOp::Rcp => {
             let op = op.to_scalar().to_f32()?;
             let div = (Single::from_u128(1).value / op).value;
diff --git a/src/tools/miri/src/shims/x86/sse.rs b/src/tools/miri/src/shims/x86/sse.rs
index 32e8e8a66c1..07a4eaa85f3 100644
--- a/src/tools/miri/src/shims/x86/sse.rs
+++ b/src/tools/miri/src/shims/x86/sse.rs
@@ -1,5 +1,4 @@
 use rustc_apfloat::ieee::Single;
-use rustc_middle::mir;
 use rustc_span::Symbol;
 use rustc_target::spec::abi::Abi;
 
@@ -29,18 +28,14 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
         // performed only on the first element, copying the remaining elements from the input
         // vector (for binary operations, from the left-hand side).
         match unprefixed_name {
-            // Used to implement _mm_{add,sub,mul,div,min,max}_ss functions.
+            // Used to implement _mm_{min,max}_ss functions.
             // Performs the operations on the first component of `left` and
             // `right` and copies the remaining components from `left`.
-            "add.ss" | "sub.ss" | "mul.ss" | "div.ss" | "min.ss" | "max.ss" => {
+            "min.ss" | "max.ss" => {
                 let [left, right] =
                     this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
 
                 let which = match unprefixed_name {
-                    "add.ss" => FloatBinOp::Arith(mir::BinOp::Add),
-                    "sub.ss" => FloatBinOp::Arith(mir::BinOp::Sub),
-                    "mul.ss" => FloatBinOp::Arith(mir::BinOp::Mul),
-                    "div.ss" => FloatBinOp::Arith(mir::BinOp::Div),
                     "min.ss" => FloatBinOp::Min,
                     "max.ss" => FloatBinOp::Max,
                     _ => unreachable!(),
@@ -65,14 +60,13 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
 
                 bin_op_simd_float_all::<Single>(this, which, left, right, dest)?;
             }
-            // Used to implement _mm_{sqrt,rcp,rsqrt}_ss functions.
+            // Used to implement _mm_{rcp,rsqrt}_ss functions.
             // Performs the operations on the first component of `op` and
             // copies the remaining components from `op`.
-            "sqrt.ss" | "rcp.ss" | "rsqrt.ss" => {
+            "rcp.ss" | "rsqrt.ss" => {
                 let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
 
                 let which = match unprefixed_name {
-                    "sqrt.ss" => FloatUnaryOp::Sqrt,
                     "rcp.ss" => FloatUnaryOp::Rcp,
                     "rsqrt.ss" => FloatUnaryOp::Rsqrt,
                     _ => unreachable!(),
@@ -82,11 +76,10 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
             }
             // Used to implement _mm_{sqrt,rcp,rsqrt}_ps functions.
             // Performs the operations on all components of `op`.
-            "sqrt.ps" | "rcp.ps" | "rsqrt.ps" => {
+            "rcp.ps" | "rsqrt.ps" => {
                 let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
 
                 let which = match unprefixed_name {
-                    "sqrt.ps" => FloatUnaryOp::Sqrt,
                     "rcp.ps" => FloatUnaryOp::Rcp,
                     "rsqrt.ps" => FloatUnaryOp::Rsqrt,
                     _ => unreachable!(),
diff --git a/src/tools/miri/src/shims/x86/sse2.rs b/src/tools/miri/src/shims/x86/sse2.rs
index 3efdd561d6c..163d74a6de4 100644
--- a/src/tools/miri/src/shims/x86/sse2.rs
+++ b/src/tools/miri/src/shims/x86/sse2.rs
@@ -227,46 +227,6 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
 
                 bin_op_simd_float_all::<Double>(this, which, left, right, dest)?;
             }
-            // Used to implement _mm_sqrt_sd functions.
-            // Performs the operations on the first component of `op` and
-            // copies the remaining components from `op`.
-            "sqrt.sd" => {
-                let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
-
-                let (op, op_len) = this.operand_to_simd(op)?;
-                let (dest, dest_len) = this.mplace_to_simd(dest)?;
-
-                assert_eq!(dest_len, op_len);
-
-                let op0 = this.read_scalar(&this.project_index(&op, 0)?)?.to_u64()?;
-                // FIXME using host floats
-                let res0 = Scalar::from_u64(f64::from_bits(op0).sqrt().to_bits());
-                this.write_scalar(res0, &this.project_index(&dest, 0)?)?;
-
-                for i in 1..dest_len {
-                    this.copy_op(&this.project_index(&op, i)?, &this.project_index(&dest, i)?)?;
-                }
-            }
-            // Used to implement _mm_sqrt_pd functions.
-            // Performs the operations on all components of `op`.
-            "sqrt.pd" => {
-                let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
-
-                let (op, op_len) = this.operand_to_simd(op)?;
-                let (dest, dest_len) = this.mplace_to_simd(dest)?;
-
-                assert_eq!(dest_len, op_len);
-
-                for i in 0..dest_len {
-                    let op = this.read_scalar(&this.project_index(&op, i)?)?.to_u64()?;
-                    let dest = this.project_index(&dest, i)?;
-
-                    // FIXME using host floats
-                    let res = Scalar::from_u64(f64::from_bits(op).sqrt().to_bits());
-
-                    this.write_scalar(res, &dest)?;
-                }
-            }
             // Used to implement the _mm_cmp*_sd functions.
             // Performs a comparison operation on the first component of `left`
             // and `right`, returning 0 if false or `u64::MAX` if true. The remaining
diff --git a/src/tools/miri/tests/fail/intrinsics/intrinsic_target_feature.rs b/src/tools/miri/tests/fail/intrinsics/intrinsic_target_feature.rs
index 9263ad381d1..860798f2ab1 100644
--- a/src/tools/miri/tests/fail/intrinsics/intrinsic_target_feature.rs
+++ b/src/tools/miri/tests/fail/intrinsics/intrinsic_target_feature.rs
@@ -24,7 +24,7 @@ fn main() {
 
     unsafe {
         // Pass, since SSE is enabled
-        addss(_mm_setzero_ps(), _mm_setzero_ps());
+        minss(_mm_setzero_ps(), _mm_setzero_ps());
 
         // Fail, since SSE4.1 is not enabled
         dpps(_mm_setzero_ps(), _mm_setzero_ps(), 0);
@@ -34,8 +34,8 @@ fn main() {
 
 #[allow(improper_ctypes)]
 extern "C" {
-    #[link_name = "llvm.x86.sse.add.ss"]
-    fn addss(a: __m128, b: __m128) -> __m128;
+    #[link_name = "llvm.x86.sse.min.ss"]
+    fn minss(a: __m128, b: __m128) -> __m128;
 
     #[link_name = "llvm.x86.sse41.dpps"]
     fn dpps(a: __m128, b: __m128, imm8: u8) -> __m128;