Closed
Description
@reduce
allows doing bitwise operations on boolean vectors, like this:
const a: @Vector(16, u8) = @splat('a');
const b: @Vector(16, u8) = @splat('b');
// false
@reduce(.Or, a == b);
However, following is not allowed:
// Vector full of dots.
const dot: @Vector(16, u8) = @splat('.');
// Vector full of spaces.
const space: @Vector(16, u8) = @splat(' ');
// Chunk we want to do search on.
const chunk: @Vector(16, u8) = "quick brown fox.".*;
// Find the occurrences of either dot or space.
const result = (chunk == dot) | (chunk == space);
error: invalid operands to binary bitwise expression: 'vector' and 'vector'
This works if the boolean vectors are casted to integer vectors with @intFromBool
:
const result = @intFromBool(chunk == dot) | @intFromBool(chunk == space);
I believe allowing the earlier would be more convenient.
Metadata
Metadata
Assignees
Labels
No labels