Commit 82520a214c

Lauri Tirkkonen <lauri@hacktheplanet.fi>
2023-06-28 12:42:43
std.crypto.hash.sha2: require avx2 on x86_64
according to https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=vpalignr&ig_expand=283,283,284,283,283&techs=AVX_ALL the vpalignr instruction requires AVX2 support
1 parent 0c1bfe2
Changed files (1)
lib
std
crypto
lib/std/crypto/sha2.zig
@@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
                         return;
                     },
                     // C backend doesn't currently support passing vectors to inline asm.
-                    .x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sha)) {
+                    .x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
                         var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
                         var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
                         const s_v = @as(*[16]v4u32, @ptrCast(&s));