默认发布版本是否始终使用 SSSE3 指令?

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

查看由 cargo (cargo build --release) 生成的二进制代码。我在二进制文件中发现使用了 SSSE3 指令,例如 pshufb

查看 cfg 我有:

$ 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

给定 SIMD ISA(AVX2 或 SSSE3)我有不同的路径,并希望有一个非 SIMD 的默认构建。

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

这是否意味着默认发布版本将始终使用最多 SSSE3 指令,而不仅仅是 x86_64 上强制要求的 SSE2?

target_os="macos"

macOS 上构建的默认版本会,是的。

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.