aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2024-02-16 08:24:26 +0100
committerJacob Young <jacobly0@users.noreply.github.com>2024-02-25 11:22:10 +0100
commita76d8ca29b98c4898d1db7db85ee1e6a781b1c0d (patch)
tree0b1394a87303546d15e20d522ae6e1a4df95adf0 /src/type.zig
parent513c4c145ee163bb178c615a216534ac1f7e9e91 (diff)
downloadzig-a76d8ca29b98c4898d1db7db85ee1e6a781b1c0d.tar.gz
zig-a76d8ca29b98c4898d1db7db85ee1e6a781b1c0d.zip
x86_64: fix alignment of bool vectors
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/type.zig b/src/type.zig
index 7e570e3bdf..a9d1654ba7 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -915,15 +915,19 @@ pub const Type = struct {
return .{ .scalar = Alignment.fromByteUnits(alignment) };
},
.stage2_x86_64 => {
- if (vector_type.child == .bool_type) return .{ .scalar = intAbiAlignment(@intCast(vector_type.len), target) };
+ if (vector_type.child == .bool_type) {
+ if (vector_type.len > 256 and std.Target.x86.featureSetHas(target.cpu.features, .avx512f)) return .{ .scalar = .@"64" };
+ if (vector_type.len > 128 and std.Target.x86.featureSetHas(target.cpu.features, .avx2)) return .{ .scalar = .@"32" };
+ if (vector_type.len > 64) return .{ .scalar = .@"16" };
+ const bytes = std.math.divCeil(u32, vector_type.len, 8) catch unreachable;
+ const alignment = std.math.ceilPowerOfTwoAssert(u32, bytes);
+ return .{ .scalar = Alignment.fromByteUnits(alignment) };
+ }
const elem_bytes: u32 = @intCast((try Type.fromInterned(vector_type.child).abiSizeAdvanced(mod, strat)).scalar);
if (elem_bytes == 0) return .{ .scalar = .@"1" };
const bytes = elem_bytes * vector_type.len;
if (bytes > 32 and std.Target.x86.featureSetHas(target.cpu.features, .avx512f)) return .{ .scalar = .@"64" };
- if (bytes > 16 and std.Target.x86.featureSetHas(
- target.cpu.features,
- if (Type.fromInterned(vector_type.child).isRuntimeFloat()) .avx else .avx2,
- )) return .{ .scalar = .@"32" };
+ if (bytes > 16 and std.Target.x86.featureSetHas(target.cpu.features, .avx)) return .{ .scalar = .@"32" };
return .{ .scalar = .@"16" };
},
}