Files
metal2vulkan/crates
Anees Iqbal c8a0481cf8 Add the bit-manipulation authored cases, qualified on Metal
What: two loop-free authored cases over `bit_ops` of the owned fixture
`engine/kernel_bit_manipulation` (f19e887e4a adds the fixture; this
commit needs it), and their Metal rows:
- `bit-manipulation-edge-words`, 16 threads:
  - the words are 0, all ones, the top bit of each width alone, one, each
    32-bit half alone, alternating bits, irregular words, 0x7f, 0x7fff
    and 1 << 32;
  - the amounts are 0, 1, 7, 8, 15, 16, 31, 32, 33, 63, 64, 65, 3, 100,
    255 and 0xffffffff.
- `bit-manipulation-mixed-words`, 32 threads in two threadgroups:
  - the words are splitmix64 of multiples of 0x1234567;
  - the amounts run from 2 to 0xfffffffe.
Each thread writes 43 words of its 48-word block: every bit intrinsic MSL
compiles to (llvm.bitreverse, bswap, fshl, fshr, ctpop, ctlz and cttz at
the fixture's widths and flags). The five other words keep the 0xab fill.

Why: the Metal evidence for the bit-manipulation lowering of f19e887e4a.

Verified (M3 Max, macOS 27.0.1, Xcode 27B52, Metal 32023.922):
- Both cases qualify on Metal. Metal's outputs (768 and 1536 words)
  equal an independent Python model of each intrinsic's LangRef
  definition: 0 mismatches.
- The MoltenVK candidate (apple-m3-max-moltenvk, moltenvk-m3, MoltenVK
  1.4.2, the product at f19e887e4a) is a Match on both cases, on the
  stated and the robustness-off legs (4 of 4).
- No RTX 5080 run: the lowering differs by device only through
  `shaderInt64`, which both the M3's MoltenVK and the 5080 have. The
  path without it (two 32-bit words) is checked against the same
  definitions on the CPU interpreter (tests::engine_bit_manipulation).
- The Metal rows are recorded under `local-metal`, as for the asm cases:
  the reference list still declares Xcode 27A266a. Neither the scratch
  reference rows nor the candidate rows are committed.
- corpus-case-check passes for both cases. The metal observation shards
  stay in (case, environment) order with one row per slot.

Golden tables: the authored compile census gains these two cases
(re-blessed on development).

(cherry picked from commit df3841734a84cce05f233bf6d0524d3c94062654)
(cherry picked from commit f7d9974009bb66bfd91270462ea1d202814b85d8)
(cherry picked from commit 160e904cc612d4dd373c57b8b4da8a53e8927bdf)
2026-11-03 02:25:31 -08:00
..