@memset beaten

This beats @memset in 0.16.0.
Another vectorization regression thingy?

fn crazy_memset(dst: []u8, value: u8) void {
    const UNROLL = std.simd.suggestVectorLength(u8) orelse @sizeOf(usize);

    var i: usize = 0;
    while (i + UNROLL <= dst.len) : (i += UNROLL) {
        const p: *align(1) @Vector(UNROLL, u8) = @ptrCast(dst[i..]);
        p.* = @splat(value);
    }
    while (i < dst.len) : (i += 1) {
        dst[i] = value;
    }
}
2 Likes

#32091

1 Like

Maybe I’ll create a PR this this in some time.

1 Like