Module vec_cmp

Module vec_cmp 

Source
Expand description

Pass: broadcast scalar operand of vec/scalar comparisons.

FunctionsΒ§

is_arith_op πŸ”’
is_compare_op πŸ”’
rewrite_vec_scalar_compare πŸ”’
HLSL auto-broadcasts the scalar operand of a comparison (vec3 >= 0.1 β†’ element-wise vec3 >= float3(0.1)); WGSL rejects vec3<f32> >= f32 with InvalidBinaryOperandTypes (a dominant validate-stage cluster, op=Ge/Le/Gt/Lt/Eq/Ne with lhs_type: Vector). Wraps the scalar operand in a vecN<f32>(…) constructor so the comparison evaluates as a vector-bool.
try_broadcast_scalar_compare πŸ”’
Inspect a comparison binop’s operands; if one is a known vector and the other is a known scalar f32, emit a constructor wrap around the scalar so the comparison evaluates as a vector-bool. Zero-length insertions only, so the wrap survives even when other passes have also edited the operands.
try_promote_i32_arith πŸ”’
Promote an i32 operand of an f32 ⟦arith⟧ i32 binop to f32 by wrapping it in float(…). WGSL refuses mixed f32 * i32 arithmetic; corpus shape (martin - pixies party 2 random mosscity.milk):
walk_block_for_vsc πŸ”’
walk_expr_for_vsc πŸ”’
walk_stmt_for_vsc πŸ”’