From fbd1463f28324737a33ed5ac7419c424d44f8a2e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 26 Jun 2018 12:05:54 +0200 Subject: [PATCH] Optimize has_cpuid for x86 Rust targets that have cpuid Improves #497. --- coresimd/x86/cpuid.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/coresimd/x86/cpuid.rs b/coresimd/x86/cpuid.rs index 3b2fed6339..6217d8824a 100644 --- a/coresimd/x86/cpuid.rs +++ b/coresimd/x86/cpuid.rs @@ -86,6 +86,14 @@ pub fn has_cpuid() -> bool { } #[cfg(target_arch = "x86")] { + // Optimization for i586 and i686 Rust targets which SSE enabled + // and support cpuid: + #[cfg(target_feature = "sse")] { + true + } + + // If SSE is not enabled, detect whether cpuid is available: + #[cfg(not(target_feature = "sse"))] unsafe { // On `x86` the `cpuid` instruction is not always available. // This follows the approach indicated in: