"""Wave64: s_cbranch_vccz/s_cbranch_vccnz must test all 64 bits of VCC when it holds data. RDNA2 ISA: VCCZ/VCCNZ test the whole 64-bit register. A shader that writes vcc_lo and vcc_hi with s_mov_b32 is using VCC as ordinary scalar data, not as a lane mask: in the translation each lane holds the same low word in %vcc and the same high word in %vcc_hi. The old branch_condition() loaded only %vcc, so a high-only non-zero VCC looked zero. Both SGPR-source and constant writes are covered: @ray3242's original reproducer uses `s_mov_b32 vcc_lo, 0` / `s_mov_b32 vcc_hi, 0x8000000a`. A VCC that was a lane mask earlier and is then overwritten with data is a separate dataflow limitation of #2544 and is not covered here. Each case is a synthetic 64-thread compute shader translated by tools/rdna2spirv.py and run with tests/semantic/spirv_mini_interp.run_workgroup; output word 0 is 7 when the branch was taken and 9 when it fell through. No llvm-mc, GPU or game data is used. """ import gc import os import struct import sys import tempfile import unittest import warnings HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = os.path.dirname(os.path.dirname(HERE)) TOOLS_DIR = os.environ.get("LEONIDA_TOOLS_DIR") or os.path.join(ROOT, "tools") sys.dont_write_bytecode = True for p in (HERE, TOOLS_DIR): if p not in sys.path: sys.path.insert(0, p) import rdna2spirv # noqa: E402 import spirv_mini_interp as si # noqa: E402 M32 = 0xFFFFFFFF STUB_DXBC = b"DXBC" + bytes(24) + struct.pack("