Skip to content

Commit

Permalink
Optimize has_cpuid for x86 Rust targets that have cpuid
Browse files Browse the repository at this point in the history
Improves rust-lang#497.
  • Loading branch information
gnzlbg committed Jun 26, 2018
1 parent fd3a3f2 commit fbd1463
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions coresimd/x86/cpuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fbd1463

Please sign in to comment.