authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-16 08:24:26+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-25 11:22:10+01:00
loga76d8ca29b98c4898d1db7db85ee1e6a781b1c0d
tree0b1394a87303546d15e20d522ae6e1a4df95adf0
parent513c4c145ee163bb178c615a216534ac1f7e9e91

x86_64: fix alignment of bool vectors


1 files changed, 9 insertions(+), 5 deletions(-)

src/type.zig+9-5
......@@ -915,15 +915,19 @@ pub const Type = struct {
915915 return .{ .scalar = Alignment.fromByteUnits(alignment) };
916916 },
917917 .stage2_x86_64 => {
918 if (vector_type.child == .bool_type) return .{ .scalar = intAbiAlignment(@intCast(vector_type.len), target) };
918 if (vector_type.child == .bool_type) {
919 if (vector_type.len > 256 and std.Target.x86.featureSetHas(target.cpu.features, .avx512f)) return .{ .scalar = .@"64" };
920 if (vector_type.len > 128 and std.Target.x86.featureSetHas(target.cpu.features, .avx2)) return .{ .scalar = .@"32" };
921 if (vector_type.len > 64) return .{ .scalar = .@"16" };
922 const bytes = std.math.divCeil(u32, vector_type.len, 8) catch unreachable;
923 const alignment = std.math.ceilPowerOfTwoAssert(u32, bytes);
924 return .{ .scalar = Alignment.fromByteUnits(alignment) };
925 }
919926 const elem_bytes: u32 = @intCast((try Type.fromInterned(vector_type.child).abiSizeAdvanced(mod, strat)).scalar);
920927 if (elem_bytes == 0) return .{ .scalar = .@"1" };
921928 const bytes = elem_bytes * vector_type.len;
922929 if (bytes > 32 and std.Target.x86.featureSetHas(target.cpu.features, .avx512f)) return .{ .scalar = .@"64" };
923 if (bytes > 16 and std.Target.x86.featureSetHas(
924 target.cpu.features,
925 if (Type.fromInterned(vector_type.child).isRuntimeFloat()) .avx else .avx2,
926 )) return .{ .scalar = .@"32" };
930 if (bytes > 16 and std.Target.x86.featureSetHas(target.cpu.features, .avx)) return .{ .scalar = .@"32" };
927931 return .{ .scalar = .@"16" };
928932 },
929933 }