Remix.run Logo
wrs 9 hours ago

Yes. "`@reduce(.And, ...)` combines every boolean using `and` and returns a single boolean."

If it's true (the common case here) then you proceed to look at the next 8 bytes.

If it's false, you apply a @bitcast (turn the booleans into bits) and @ctz (find the first 0) to get the index of where it was false.

tapirl 7 hours ago | parent [-]

Maybe I'm wrong, but should it be @clz instead?

wrs 7 hours ago | parent [-]

No, the diagram looks like a binary literal but it's actually backwards from that. Lane 0 becomes the LSB, but that's on the left of the diagram.

tapirl 7 hours ago | parent [-]

Aha, you are right. Smaller indexes are for least-significant bits.