Skip to content

Commit 709f7e0

Browse files
authored
Enable SSE 4.2 unconditionally (#3833)
* Enable SSE 4.2 unconditionally Fuzzing over the weekend found that `i64x2` comparison operators require `pcmpgtq` which is an SSE 4.2 instruction. Along the lines of #3816 this commit unconditionally enables and requires SSE 4.2 for compilation and fuzzing. It will no longer be possible to create a compiler for x86_64 with simd enabled if SSE 4.2 is disabled. * Update comment
1 parent 43d31c5 commit 709f7e0

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

cranelift/codegen/meta/src/isa/x86.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn define_settings(shared: &SettingGroup) -> SettingGroup {
3838
"has_sse42",
3939
"Has support for SSE4.2.",
4040
"SSE4.2: CPUID.01H:ECX.SSE4_2[bit 20]",
41-
false,
41+
true,
4242
);
4343
let has_avx = settings.add_bool(
4444
"has_avx",

cranelift/codegen/src/isa/x64/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@ fn isa_constructor(
178178
let isa_flags = x64_settings::Flags::new(&shared_flags, builder);
179179

180180
// Check for compatibility between flags and ISA level
181-
// requested. In particular, SIMD support requires SSE4.1.
181+
// requested. In particular, SIMD support requires SSE4.2.
182182
if shared_flags.enable_simd() {
183-
if !isa_flags.has_sse3() || !isa_flags.has_ssse3() || !isa_flags.has_sse41() {
183+
if !isa_flags.has_sse3()
184+
|| !isa_flags.has_ssse3()
185+
|| !isa_flags.has_sse41()
186+
|| !isa_flags.has_sse42()
187+
{
184188
return Err(CodegenError::Unsupported(
185-
"SIMD support requires SSE3, SSSE3, and SSE4.1 on x86_64.".into(),
189+
"SIMD support requires SSE3, SSSE3, SSE4.1, and SSE4.2 on x86_64.".into(),
186190
));
187191
}
188192
}
@@ -354,6 +358,7 @@ mod test {
354358
isa_builder.set("has_sse3", "false").unwrap();
355359
isa_builder.set("has_ssse3", "false").unwrap();
356360
isa_builder.set("has_sse41", "false").unwrap();
361+
isa_builder.set("has_sse42", "false").unwrap();
357362
assert!(matches!(
358363
isa_builder.finish(shared_flags),
359364
Err(CodegenError::Unsupported(_)),

crates/fuzzing/src/generators.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ impl<'a> Arbitrary<'a> for CodegenSettings {
756756
std:"sse3" => clif:"has_sse3" ratio: 1 in 1,
757757
std:"ssse3" => clif:"has_ssse3" ratio: 1 in 1,
758758
std:"sse4.1" => clif:"has_sse41" ratio: 1 in 1,
759+
std:"sse4.2" => clif:"has_sse42" ratio: 1 in 1,
759760

760-
std:"sse4.2" => clif:"has_sse42",
761761
std:"popcnt" => clif:"has_popcnt",
762762
std:"avx" => clif:"has_avx",
763763
std:"avx2" => clif:"has_avx2",

crates/wasmtime/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ impl Config {
554554
/// this does not enable the [relaxed simd proposal] as that is not
555555
/// implemented in Wasmtime at this time.
556556
///
557+
/// On x86_64 platforms note that enabling this feature requires SSE 4.2 and
558+
/// below to be available on the target platform. Compilation will fail if
559+
/// the compile target does not include SSE 4.2.
560+
///
557561
/// This is `true` by default.
558562
///
559563
/// [proposal]: https://github.com/webassembly/simd

0 commit comments

Comments
 (0)