def select

stelliferous@0.0.2.0 · math_compare.bend:90

import stelliferous@0.0.2.0/math_compare.bend as MathCompare
import Base
import stelliferous@0.0.2.0/math_fp32.bend as FP32

90# Selection only changes words; the chosen payload is never FP arithmetic.
91# selected is 0 or all ones, so selected + 1 is 1 or 0 modulo 2^32.
92# This masked integer product keeps the native selection in value lanes.
93def select(mask: F32,yes: F32,no: F32) -> F32:
94  +magnitude = U32.and(F32.bits(mask),2147483647)
95  +selected = (0 - U32.shrn((magnitude + 2147483647 : U32),31n) : U32)
96  +no = F32.bits(no)
97  FP32.from_bits((U32.and(F32.bits(yes),selected) + no * (selected + 1 : U32) : U32))

Uses (9)

Used by (3)