Both interpreters accept OpTypeInt 64 but treated a 64-bit operand of
OpBitCount, SMin, SMax, SClamp, SAbs, FindILsb, FindUMsb and FindSMsb as
32-bit: OpBitCount of 0xFFFFFFFF00000000 gave 0, and SMin(2^31, 1) on a
64-bit type gave 2^31.
OpBitCount now counts every bit of its operand's type, and SMin, SMax,
SClamp and SAbs read their operands as signed at the width of their type.
FindILsb, FindUMsb and FindSMsb raise UnsupportedConstruct for a type that
is not 32-bit, since GLSL.std.450 limits them to 32-bit components. Results
for 32-bit types are unchanged.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The wave interpreter stores integers as unsigned bit patterns. Normalize each switch literal to the selector width so a negative case reaches its target.
tools/cf_diff.py generates seeded wave32/wave64 pixel shaders from the
control-flow shapes compilers emit (saveexec if/else, v_cmpx, VCC- and
SCC-voted branches, uniform and per-lane loops, two-entry cycles) and
compares every lane's export between:
* tools/cf_ref.py: cpu_ref's Machine plus branches, compares, v_cmpx,
saveexec and 64-bit masks (the ISA model, one wave)
* rdna2spirv + tests/semantic/spirv_wave_interp.py: every invocation of
one subgroup in lockstep, split at selections and rejoined at merges,
with the subgroup operations the translator emits
in both the structured and the dispatch-loop form; --spirv-val also
validates each module, --minimize reduces a mismatch.
Finding (fixed here): in a wave32 program s_and/or/xor/andn2/orn2/nand/
nor/xnor_b32 on lane masks set SCC from the lane's own bit instead of the
whole mask, so `s_and_b32 s0, vcc_lo, exec_lo; s_cbranch_scc0` and loops
closed by `s_andn2_b32 exec_lo, ...; s_cbranch_scc1` split the wave. SCC
is now the same subgroup vote as for the _b64 forms. GPU test
ps_scc_mask32 (not run on a GPU yet).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>