← All examples

SIMD fold shift

A vector folded to one lane gives a shift the lane's width: simd.max['s'] of uint8 lanes is a uint8, so shl 1 is an 8-bit shift.

simd_fold_shift.zg
# A vector folded to one lane gives a shift the lane's width (check claude, seed 4094): `simd.max['s']`
# of uint8 lanes is a uint8, so `shl 1` is an 8-bit shift.
MAIN {
    let 's': simd[uint8, 16] = simd.fill[value 3];
    std::print.useful[simd.max['s'] shl 1, newln];
}
Output
6