about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2022-01-20 15:48:46 -0800
committerJubilee <46493976+workingjubilee@users.noreply.github.com>2022-01-20 19:22:14 -0800
commit56566d816deda17b2ddaf3e3e603f2af16e26653 (patch)
treef8f31812ac3dc3b5c3f4abae18d98df71ef42cd4
parenta4f5f01b8aa92780e695d471e72e699ef10abe30 (diff)
downloadrust-56566d816deda17b2ddaf3e3e603f2af16e26653.tar.gz
rust-56566d816deda17b2ddaf3e3e603f2af16e26653.zip
Annotate signed type in int_divrem_guard
The way the macro expands, it may sometimes infer
"this is a uint, but doesn't impl Neg???"
Also, I made the "wrong path for intrinsics" error.
These fixes allow integration into libcore.
-rw-r--r--crates/core_simd/src/ops.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/core_simd/src/ops.rs b/crates/core_simd/src/ops.rs
index 82b007aa696..b65038933bf 100644
--- a/crates/core_simd/src/ops.rs
+++ b/crates/core_simd/src/ops.rs
@@ -33,7 +33,7 @@ where
 
 macro_rules! unsafe_base {
     ($lhs:ident, $rhs:ident, {$simd_call:ident}, $($_:tt)*) => {
-        unsafe { $crate::intrinsics::$simd_call($lhs, $rhs) }
+        unsafe { $crate::simd::intrinsics::$simd_call($lhs, $rhs) }
     };
 }
 
@@ -49,7 +49,10 @@ macro_rules! unsafe_base {
 macro_rules! wrap_bitshift {
     ($lhs:ident, $rhs:ident, {$simd_call:ident}, $int:ident) => {
         unsafe {
-            $crate::intrinsics::$simd_call($lhs, $rhs.bitand(Simd::splat(<$int>::BITS as $int - 1)))
+            $crate::simd::intrinsics::$simd_call(
+                $lhs,
+                $rhs.bitand(Simd::splat(<$int>::BITS as $int - 1)),
+            )
         }
     };
 }
@@ -70,11 +73,13 @@ macro_rules! int_divrem_guard {
         if $rhs.lanes_eq(Simd::splat(0)).any() {
             panic!($zero);
         } else if <$int>::MIN != 0
-            && ($lhs.lanes_eq(Simd::splat(<$int>::MIN)) & $rhs.lanes_eq(Simd::splat(-1 as _))).any()
+            && ($lhs.lanes_eq(Simd::splat(<$int>::MIN))
+                // type inference can break here, so cut an SInt to size
+                & $rhs.lanes_eq(Simd::splat(-1i64 as _))).any()
         {
             panic!($overflow);
         } else {
-            unsafe { $crate::intrinsics::$simd_call($lhs, $rhs) }
+            unsafe { $crate::simd::intrinsics::$simd_call($lhs, $rhs) }
         }
     };
 }