authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2025-01-26 02:31:32+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-26 07:00:24-08:00
logdf1cd62720138122a9389d78df5187af7c577e24
tree8879969157289f63bd8ec37f00a18730c5299531
parent92b20e42162675d35ffd27845e66b0f9213c00c2

compiler-rt: ensure memcpy Element has no unused bytes


1 files changed, 10 insertions(+), 8 deletions(-)

lib/compiler_rt/memcpy.zig+10-8
......@@ -18,16 +18,18 @@ comptime {
1818 }
1919}
2020
21const Element = if (std.simd.suggestVectorLength(u8)) |vec_size|
22 @Type(.{ .vector = .{
23 .child = u8,
24 .len = vec_size,
25 } })
26else
27 usize;
21const Element = Element: {
22 if (std.simd.suggestVectorLength(u8)) |vec_size| {
23 const Vec = @Vector(vec_size, u8);
24
25 if (@sizeOf(Vec) == vec_size and std.math.isPowerOfTwo(vec_size)) {
26 break :Element Vec;
27 }
28 }
29 break :Element usize;
30};
2831
2932comptime {
30 assert(@sizeOf(Element) >= @alignOf(Element));
3133 assert(std.math.isPowerOfTwo(@sizeOf(Element)));
3234}
3335