flowchart TD H["HLSL: while (true) {
if (key == WaveReadLaneFirst(key)) {
sum = WaveActiveSum(v); break; } }"] --> D["DXC: the break becomes
if (dx.break.cond[0] == 0) break
dx.break.cond = constant zero"] D -->|before| P["dxil-spirv: Private array with initializer
SPIRV-Cross: promoted to a constant array"] D -->|now| V["dxil-spirv patch 0006: decorated Volatile
SPIRV-Cross patch 0043: read through
*(volatile thread uint*)&_14[0u]
(_14 is the array's generated name)"] P --> F["Metal compiler folds the test:
the break is always taken,
simd_sum moves after the loop"] F --> X["every lane gets the whole wave's sum
25 25 25 25 ..."] V --> K["Metal compiler can't fold the load:
simd_sum stays in the loop"] K --> OK["each iteration sums its own lanes
12 9 4 9 12 0 0 4 ... (as on D3D)"]