Skip to content

Commit 5276f2b

Browse files
committed
TD-T22: tighten the "zero scalar ALU" claim to what was actually measured
Self-caught overclaim in the previous commit. I wrote "0 scalar ALU" from a narrow grep for `(add|sub|xor|rol|ror|shl|shr|or|and)[lqwb]`. A broad sweep of ALL non-vector instructions across the three probe symbols returns: 3 retq 1 movl 1 jne 1 decl The `decl` IS a scalar ALU instruction — it decrements the `arx_ten_rounds` loop trip count. So "zero scalar ALU instructions" is literally false. The claim that survives, and the one the finding actually rests on: **no scalar operation touches lane data.** Every u32 lane op in all three probes is a packed AVX2 instruction; the only scalar work is loop control. Corrected in both sites and stated explicitly in the artifact, since a knowledge doc that overstates its own measurement is the failure mode this investigation exists to document.
1 parent 5bd1e4b commit 5276f2b

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎.claude/knowledge/agnostic-surface-cpu-matrix.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ than real `__m256i` intrinsics. Needs verification (see § J integration plan).
102102
> the answer is: the storage IS scalar in the SOURCE, and that costs nothing.
103103
> `.cargo/config.toml` pins `-Ctarget-cpu=x86-64-v3` for every x86_64 build,
104104
> so LLVM auto-vectorizes the `avx2_int_type!` loop bodies into packed AVX2.
105-
> Measured on the ChaCha20 ARX triple over `U32x16`: **zero scalar ALU
106-
> instructions**, `rotate_left(16)` strength-reduced to `vpshufb`, and the
105+
> Measured on the ChaCha20 ARX triple over `U32x16`: **no scalar arithmetic
106+
> touches lane data** (the only non-vector ops across all three probes are
107+
> `retq` and the loop's `movl`/`decl`/`jne` trip counter),
108+
> `rotate_left(16)` strength-reduced to `vpshufb`, and the
107109
> 10-round double-round loop emits exactly **8 `vpaddd` for 64 u32 lanes** —
108110
> the AVX2 instruction-count floor, with no headroom a hand-written
109111
> `__m256i` version could recover. `reduce_sum` emits a logarithmic

‎.claude/knowledge/td-t22-asm-investigation.md‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ cargo rustc --release --example td_t22_probe -p ndarray -- --emit asm -C debugin
8383
| `vpxor` | 2 |
8484
| `vpshufb` | 2 |
8585
| `vmovdqa` | 5 |
86-
| **scalar ALU** | **0** |
86+
| **scalar arithmetic on lane data** | **0** |
8787

8888
16 u32 lanes = 2 ymm registers, so 2 packed ops per lane-op is exactly one
8989
instruction per half. LLVM strength-reduced `rotate_left(16)` into a **byte
@@ -99,7 +99,7 @@ intrinsic version would emit.
9999
| `vpshufb` | 6 |
100100
| `vpsrld` / `vpslld` / `vpor` | 4 / 4 / 4 |
101101
| `jne` | 1 |
102-
| **scalar ALU** | **0** |
102+
| **scalar arithmetic on lane data** | **0** |
103103

104104
The `jne` shows this is one rolled loop body, so the counts are per
105105
iteration. **This is the instruction-count floor:** 4 `U32x16` adds = 64 u32
@@ -116,11 +116,20 @@ for a hand-written version to recover.**
116116
| `vpshufd` | 2 |
117117
| `vextracti128` | 1 |
118118
| `vmovd` | 1 |
119-
| **scalar ALU** | **0** |
119+
| **scalar arithmetic on lane data** | **0** |
120120

121121
A textbook logarithmic horizontal-reduction tree, not the scalar
122122
`wrapping_add` fold the source literally spells out.
123123

124+
**Precision on "0 scalar arithmetic on lane data".** A broad sweep of ALL
125+
non-vector instructions across the three symbols returns exactly:
126+
`3 retq`, `1 movl`, `1 jne`, `1 decl`. The `movl`/`decl`/`jne` are the
127+
`arx_ten_rounds` loop counter and branch — loop control, not lane
128+
arithmetic. So the honest claim is **no scalar op touches lane data**, not
129+
"no scalar instruction exists": one `decl` does, and it decrements the trip
130+
count. Every `u32` lane operation in all three probes is a packed AVX2
131+
instruction.
132+
124133
## The same result holds for the float side
125134

126135
`F32x16::mul_add` (`simd_avx2.rs`) is likewise written as

0 commit comments

Comments
 (0)