P3642R4 — Carry-less product: std::clmul
(8 items)
LEWG
This paper proposes adding carry-less multiplication (XOR multiplication) functions to the C++ standard library in the header. It introduces std::clmul for non-widening carry-less multiplication and std::clmul_wide for a widening variant returning a wide_result struct containing low and high bits, along with std::simd overloads for SIMD vector types. The operation is motivated by applications in CRC computation, AES-GCM cryptography, JSON parsing, and space-filling curve generation, with widespread hardware support via PCLMULQDQ (x86), PMULL (ARM), and CLMUL (RISC-V) instructions.
- §5.3 / [simd.clmul] — The SIMD overload of clmul takes a single parameter v, and its Returns clause calls clmul(v[i]) with one argument, but the scalar clmul in [numeric.clmul] requires two arguments (T x, T y). No single-argument overload exists. The SIMD overload should take two parameters and the Returns clause should call clmul(x[i], y[i]). [1]
- §4 (Possible implementation), SIMD note block — The powers array starts with 0 instead of 1. Since T{1} << 0 == 1, the first element should be 1, making the array { 1, 2, 4, 8, 16, ... }. [2]
- Drafting note after [numeric.clmul] wording — The TeX transcription uses x_i but the normative MathML formula uses x_j with j as the summation index. The TeX should read c_i = bigoplus_{j=0}^{i} x_j y_{i-j}. [3]
- §3 (Motivation), bit manipulation bullet — std::bit_compressr is misspelled with a stray trailing r. The function is named std::bit_compress in P3104R3 and throughout the rest of this paper. [4]
- §4.1 (Hardware support), table — The row for clmul u64 to u128 with instructions pclmulqdq / pmull+pmull2 / clmul+clmulh appears twice consecutively with identical content. One duplicate should be removed. [5]
- §7 (References), [FastHilbertCurves] — The URL contains a leading double-quote character (percent-encoded as %22), making the link invalid. Should be http://threadlocalmutex.com/?p=188 without the leading quote. [6]
References — Anthropic Citations API
[1]
"this proposal provides non-widening SIMD carry-less multiplication with the following signature: template constexpr V clmul(const V& v) noexcept; and the Returns clause: A basic_vec..."
"this proposal provides non-widening SIMD carry-less multiplication with the following signature: template
[2]
"This is utilized in the reference implementation [BitPermutations] of std::bit_compressr, proposed in [P3104R3]."
"This is utilized in the reference implementation [BitPermutations] of std::bit_compressr, proposed in [P3104R3]."
[3]
"c_i = \bigoplus_{j = 0}^i x_i y_{i - j}"
"c_i = \bigoplus_{j = 0}^i x_i y_{i - j}"
[4]
"static constexpr V powers = array{ 0, 1, 2, 4, 8, /* ... */ };"
"static constexpr V powers = array
[5]
"Two consecutive identical rows: clmul u64 → u128 | pclmulqdq | pmull+pmull2 | clmul+clmulh"
"Two consecutive identical rows: clmul u64 → u128 | pclmulqdq | pmull+pmull2 | clmul+clmulh"
[6]
""http://threadlocalmutex.com/?p=188"
""http://threadlocalmutex.com/?p=188"
Summary: P3642R4 proposes std::clmul, a carry-less multiplication function for unsigned integer types, along with a std::simd overload. Six defects were found spanning a signature mismatch in the SIMD overload, incorrect example values, a misspelled identifier, a TeX transcription error, a duplicate table row, and a broken reference URL.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.