Skip to content

_mm_pause does not require SSE2 #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions crates/core_arch/src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ use crate::{
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_pause)
#[inline]
#[target_feature(enable = "sse2")]
#[cfg_attr(test, assert_instr(pause))]
#[cfg_attr(
all(test, target_feature = "sse2"),
assert_instr(pause)
)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_pause() {
// note: `pause` is guaranteed to be interpreted as a `nop` by CPUs without
// the SSE2 target-feature - therefore it does not require any target features
pause()
}

Expand Down Expand Up @@ -3191,9 +3195,9 @@ mod tests {
use stdsimd_test::simd_test;
use test::black_box; // Used to inhibit constant-folding.

#[simd_test(enable = "sse2")]
unsafe fn test_mm_pause() {
_mm_pause();
#[test]
fn test_mm_pause() {
unsafe { _mm_pause() }
}

#[simd_test(enable = "sse2")]
Expand Down
10 changes: 5 additions & 5 deletions crates/stdsimd-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn arm_functions(input: TokenStream) -> TokenStream {

fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
let dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let root = dir.parent().unwrap();
let root = dir.parent().expect("root-dir not found");

let mut files = Vec::new();
for dir in dirs {
Expand Down Expand Up @@ -199,11 +199,11 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
if path.segments.len() != 1 {
panic!("unsupported path that needs name resolution")
}
match path.segments.first().unwrap().value().arguments {
match path.segments.first().expect("segment not found").value().arguments {
syn::PathArguments::None => {}
_ => panic!("unsupported path that has path arguments"),
}
path.segments.first().unwrap().value().ident.clone()
path.segments.first().expect("segment not found").value().ident.clone()
}

fn walk(root: &Path, files: &mut Vec<(syn::File, String)>) {
Expand All @@ -224,9 +224,9 @@ fn walk(root: &Path, files: &mut Vec<(syn::File, String)>) {

let mut contents = String::new();
File::open(&path)
.unwrap()
.expect(&format!("can't open file at path: {}", path.display()))
.read_to_string(&mut contents)
.unwrap();
.expect("failed to read file to string");

files.push((
syn::parse_str::<syn::File>(&contents).expect("failed to parse"),
Expand Down
6 changes: 6 additions & 0 deletions crates/stdsimd-verify/tests/x86-intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> {
}

for cpuid in &intel.cpuid {
// The pause intrinsic is in the SSE2 module, but it is backwards
// compatible with CPUs without SSE2, and it therefore does not need the
// target-feature attribute.
if rust.name == "_mm_pause" {
continue;
}
// this is needed by _xsave and probably some related intrinsics,
// but let's just skip it for now.
if *cpuid == "XSS" {
Expand Down