Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will a default release build always use up to SSSE3 instructions?

Looking at the code of a binary produced by cargo (cargo build --release). I found in the binary that SSSE3 instructions like pshufb were used.

Looking at cfg I have:

$ rustc --print cfg
debug_assertions
target_arch="x86_64"
target_endian="little"
target_env=""
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_feature="sse3"
target_feature="ssse3"
target_os="macos"
target_pointer_width="64"
target_vendor="apple"
unix

I have different paths given the SIMD ISA (AVX2 or SSSE3) and expected to have a non SIMD one with the default build.

#[cfg(target_feature = "avx2")]
{
    ...
    return;
}
#[cfg(target_feature = "ssse3")]
{
    ...
    return;
}
// portable Rust code at the end
...

Does this mean that a default release build will always use up to SSSE3 instructions, and not just SSE2 which is mandatory on x86_64?

like image 686
Stringer Avatar asked Mar 04 '23 16:03

Stringer


1 Answers

target_os="macos"

A default release build on macOS will, yes.

Since Apple has never sold any AMD or Pentium4 CPUs, x86-64 on OS X also implies SSSE3 (first-gen Core2). The first x86 Macs were Core (not Core2), but they were 32-bit only. You unfortunately can't assume SSE4.1 or -mpopcnt.

  • What is the minimum supported SSE flag that can be enabled on macOS?
like image 190
Shepmaster Avatar answered Mar 06 '23 05:03

Shepmaster