compiler-rt: ensure memcpy Element has no unused bytes

This commit is contained in:
dweiller 2025-01-26 02:31:32 +11:00 committed by Andrew Kelley
parent 92b20e4216
commit df1cd62720

View File

@ -18,16 +18,18 @@ comptime {
}
}
const Element = if (std.simd.suggestVectorLength(u8)) |vec_size|
@Type(.{ .vector = .{
.child = u8,
.len = vec_size,
} })
else
usize;
const Element = Element: {
if (std.simd.suggestVectorLength(u8)) |vec_size| {
const Vec = @Vector(vec_size, u8);
if (@sizeOf(Vec) == vec_size and std.math.isPowerOfTwo(vec_size)) {
break :Element Vec;
}
}
break :Element usize;
};
comptime {
assert(@sizeOf(Element) >= @alignOf(Element));
assert(std.math.isPowerOfTwo(@sizeOf(Element)));
}