about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-09-06 20:08:04 +0200
committerGitHub <noreply@github.com>2022-09-06 20:08:04 +0200
commitd8b382105f1cb6faeb7e500481720d3433bf87ae (patch)
tree24bf97aa1864d89b392b3e8b4596823c781a9f7e
parent3c7278846102bb829c9a789e91bc43f0ed612943 (diff)
downloadrust-d8b382105f1cb6faeb7e500481720d3433bf87ae.tar.gz
rust-d8b382105f1cb6faeb7e500481720d3433bf87ae.zip
Compile spin_loop_hint as pause on x86 even without sse2 enabled
The x86 `pause` instruction was introduced with sse2, but because it is encoded as `rep nop`, it works just fine on cpu's without sse2 support. It just doesn't do anything.
-rw-r--r--library/core/src/hint.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs
index 20340d42962..764e2796202 100644
--- a/library/core/src/hint.rs
+++ b/library/core/src/hint.rs
@@ -160,19 +160,16 @@ pub const unsafe fn unreachable_unchecked() -> ! {
 #[inline]
 #[stable(feature = "renamed_spin_loop", since = "1.49.0")]
 pub fn spin_loop() {
-    #[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2"))]
+    #[cfg(target_arch = "x86")]
     {
-        #[cfg(target_arch = "x86")]
-        {
-            // SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
-            unsafe { crate::arch::x86::_mm_pause() };
-        }
+        // SAFETY: the `cfg` attr ensures that we only execute this on x86 targets.
+        unsafe { crate::arch::x86::_mm_pause() };
+    }
 
-        #[cfg(target_arch = "x86_64")]
-        {
-            // SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
-            unsafe { crate::arch::x86_64::_mm_pause() };
-        }
+    #[cfg(target_arch = "x86_64")]
+    {
+        // SAFETY: the `cfg` attr ensures that we only execute this on x86_64 targets.
+        unsafe { crate::arch::x86_64::_mm_pause() };
     }
 
     // RISC-V platform spin loop hint implementation