tiny.simd.copyIf
Defined in algo.
Source
Source: lib/simd/src/algo.zig:31
zig
pub fn copyIf( comptime D: type, input: []const D.Lane, output: []D.Lane, predicate: anytype,) usize { if (@sizeOf(D.Lane) == 1) @compileError("copyIf requires 16/32/64-bit lanes"); std.debug.assert(output.len >= input.len); var input_index: usize = 0; var output_index: usize = 0; while (input_index + D.lane_count <= input.len) : (input_index += D.lane_count) { const value = memory.load(D, input[input_index..]); output_index += compact.compressBlendedStore( D, value, predicate.call(D, value), output[output_index..], ); } if (input_index != input.len) { const remaining = input.len - input_index; const value = memory.loadN(D, input[input_index..], remaining); const mask = predicate.call(D, value) & construct.firstN(D, remaining); output_index += compact.compressBlendedStore(D, value, mask, output[output_index..]); } std.debug.assert(output_index <= input.len); return output_index;}Source: lib/simd/src/root.zig:456
zig
pub const copyIf = algo.copyIf;Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |