Plain Raya integer loops, faster than C
Write ordinary integer loops over typed lists (dot products, polynomial products, matrix products, FIR filters, 2-D convolutions) and Raya's compiler runs them faster than gcc and clang at -O3 -march=native, with the same results bit for bit, on AWS Graviton3 and Graviton4, Intel Sapphire Rapids and Ice Lake, and AMD EPYC Zen 4.
1 December 2026. Samario Torres, Riptide.
What you can do
Write the loop the way the maths reads, over Uint8List, Int16List, Int32List or Int64List, and compile it with raya compile exe. These run faster than the same loops in C compiled by gcc 13 or clang 18 at -O3 -march=native, on every one of the five server CPUs we measured (one exception, for the compiler's own code: a 16 × 16 product into an Int64List on EPYC Zen 4, 0.87× clang), and give exactly the same results:
- Byte dot products:
s += a[i] * b[i]. - Polynomial products of byte counts:
c[i + j] += a[i] * b[j]. - Matrix products of byte matrices, in row form (
c[i * n + j] += a[i * n + k] * b[k * n + j]) or dot form (s += a[i * n + k] * bt[j * n + k]; c[i * n + j] = s). - FIR filters with
int8orint16taps over byte samples:y[i] += h[k] * x[i + k]. - 2-D convolutions of byte images with
int16kernels, four loops deep.
How much faster, as the faster C compiler's time over Raya's (more than 1× is a win for Raya):
| Loop | Graviton3 | Graviton4 | Sapphire Rapids | Ice Lake | EPYC Zen 4 |
|---|---|---|---|---|---|
| Byte dot product, 4K pairs | 11.3× | 8.95× | 5.89× | 4.43× | 3.33× |
| Byte dot product, 64K pairs | 12.0× | 9.22× | 6.29× | 4.07× | 4.63× |
| Byte dot product, 1M pairs | 9.58× | 7.76× | 4.26× | 2.33× | 3.99× |
| Polynomial product 64 × 64 → Int64List | 2.03× | 2.50× | 2.93× | 1.62× | 2.58× |
| Polynomial product 64 × 64 → Int32List | 1.27× | 1.63× | 2.71× | 1.66× | 2.48× |
| Polynomial product 256 × 256 → Int32List | 3.87× | 4.30× | 5.29× | 2.98× | 3.49× |
| Polynomial product 256 × 256 → Int64List | 8.06× | 7.80× | 9.87× | 6.25× | 6.21× |
| Polynomial product 1024 × 1024 → Int32List | 5.75× | 5.55× | 8.69× | 4.63× | 5.03× |
| Polynomial product 1024 × 1024 → Int64List | 12.2× | 10.5× | 17.6× | 8.79× | 9.32× |
| Polynomial product 4096 × 4096 → Int32List | 6.38× | 5.76× | 11.0× | 5.26× | 5.83× |
| Polynomial product 4096 × 4096 → Int64List | 13.8× | 11.0× | 21.4× | 10.3× | 12.5× |
| Byte matrix product 64 × 64, dot form | 3.57× | 3.81× | 8.14× | 6.28× | 4.90× |
| Byte matrix product 64 × 64, row form | 4.08× | 5.31× | 4.13× | 2.86× | 6.89× |
| Byte matrix product 256 × 256, dot form | 4.38× | 5.51× | 26.0× | 11.9× | 5.75× |
| Byte matrix product 256 × 256, row form | 7.54× | 7.52× | 15.7× | 7.55× | 6.58× |
| Byte matrix product 512 × 512, dot form | 5.17× | 5.77× | 42.5× | 13.5× | 5.81× |
| Byte matrix product 512 × 512, row form | 8.21× | 9.31× | 25.1× | 7.97× | 6.12× |
| FIR filter, 16 taps, 64K samples | 2.84× | 2.97× | 4.26× | 3.10× | 2.71× |
| FIR filter, 16 taps, 1M samples | 3.31× | 3.82× | 5.94× | 5.20× | 3.13× |
| 3 × 3 convolution, 256 × 256 bytes | 1.46× | 1.56× | 2.05× | 1.67× | 1.38× |
| 3 × 3 convolution, 1024 × 1024 bytes | 1.82× | 2.09× | 3.78× | 2.96× | 1.82× |
Geometric mean over the 21 loops, per CPU: Graviton3 4.9×, Graviton4 5.0×, Sapphire Rapids 7.9×, Ice Lake 4.5×, EPYC Zen 4 4.4×.
This table and the per-CPU tables below measure the kernel path: the compiler finds the nest and calls a tuned runtime kernel. For byte dot products and polynomial products the compiler now writes the vector code itself, which is faster again for small and medium nests; see Vector code the compiler writes itself.
Setup: none. It is on in every AOT build (raya compile exe app.ray).
How it gets there
For matrix products, FIR filters and 2-D convolutions, the win comes from the compiler recognising the loop nest and choosing a kernel tuned for the CPU it runs on. For byte dot products and polynomial products, the compiler now writes the vector code itself, in place, with no kernel call (next section). Outside these shapes the compiler's general code is not yet better than gcc's or clang's: with recognition off, Raya's own vectoriser beats C only on byte dot products (12 of 105 measurements).
- The compiler finds the nest. Raya's AOT front end looks for rectangular loop nests up to four deep whose bounds don't change inside the nest and whose every index is linear in the loop counters (
i * n + k,(y + dy) * w + dx + x). The body must be one multiply-add into a list (dst[..] += x[..] * y[..]) or a sum that is then stored or returned.finallocals holding an index or one factor may sit between the loops, and so mayif (factor == 0) continue;. - It puts one call in front of the nest. The call gets the lists, the bounds and every index as a base plus one coefficient per loop. The loops stay in the program, unchanged, behind it.
- The runtime picks the kernel at start-up. It reads the CPU's features once and names a family: AVX-512 VNNI (
VPDPBUSD,VPDPWSSD) on Ice Lake and Zen 4, plus AMX-INT8 tiles (TDPBUUD) for matrix products on Sapphire Rapids; NEONUDOT,USDOTandUMMLAon Graviton4; and on Graviton3 the same, with 256-bit SVE for the longer correlations and dot products. Each kernel blocks its loops for that machine: how many outputs stay in registers, how the operands are packed, where the vector width changes. - The call does the whole nest, or nothing. If the shape is one it has a kernel for, it checks every index the nest would touch and that the destination's memory overlaps neither source, then runs the kernel and the loops are skipped. Otherwise it writes nothing and the loops run as written.
For one-loop element-wise work (c[i] = a[i] + b[i], masks, shifts, sums) the compiler's own integer vectoriser does the job; see SIMD.
Exactness
The results are the loops' results, bit for bit, on every CPU.
- Reordering is exact. Raya's
intwraps modulo 2⁶⁴, and a 32-bit list stores the low 32 bits, so adding the same products in another order gives the same bits. - Partial sums never overflow where it matters. The kernels add in 32-bit lanes. That is exact for destinations of 32 bits or fewer. For 64-bit destinations the work is cut into chunks small enough that no 32-bit partial sum can leave its range (65,536 byte-by-byte products, 256 for
int16taps), and each chunk is added in 64 bits. - Signed and unsigned bytes. x86's
VPDPBUSDmultiplies unsigned bytes by signed bytes. For unsigned × unsigned one side is moved to signed (b − 128) and 128 times the other side's sum is added back.int16taps on Arm are split into a low byte (unsigned,UDOT) and a high byte (signed,USDOT). - Errors and partial writes stay the same. The call writes nothing unless every index is in range, so an out-of-range index or a destination that shares memory with a source gives the same
RangeError, after the same writes, as before.
The test raya_nest_kernels_test.ray compares every shape with the same loops compiled without the pass: random data and each type's edge values, every length and start in a range, odd sizes, narrow, 32-bit and 64-bit destinations, reversed loops and offsets, out-of-range bounds and a destination sharing memory with a source. It runs once for each kernel family the CPU has, once with the widest kernels at every size, once with the kernels off and once with the vectoriser off, and checks that the kernels ran. benchmarks/RayaIntVec/kernels/nest_kernels_test.cc checks the kernels alone against the scalar nest, for every family, on each CPU.
Results per CPU
These are the kernel-path measurements (benchmarks/RayaIntVec/results/2026-12-01-nest/). Time per call, one thread, best of five blocks of at least 60 ms. Every implementation is checked against a scalar reference before it is timed. C is benchmarks/RayaIntVec/c/intvec_bench.c, the same loops written plainly, compiled on each machine with gcc 13.3 and with clang 18.1 at -O3 -march=native. "Hand intrinsics" are the same operations written by hand with Raya's raya:simd intrinsics (their x86 fallback is scalar, which is why they are slow there). "Raya without the kernels" is the same build with --no-raya-nest-kernels: the integer vectoriser alone. AWS us-west-2, 2-vCPU instances.
AWS Graviton3 (Neoverse V1)
| Loop | Raya | gcc 13 | clang 18 | Raya vs the faster C | Hand intrinsics | Raya without the kernels | Kernel |
|---|---|---|---|---|---|---|---|
| Byte dot product, 4K pairs | 137 ns | 1.56 µs | 1.59 µs | 11.3× faster | 770 ns | 224 ns | NEON UDOT |
| Byte dot product, 64K pairs | 2.11 µs | 25.3 µs | 25.3 µs | 12.0× faster | 12.6 µs | 3.63 µs | NEON UDOT |
| Byte dot product, 1M pairs | 42.3 µs | 405 µs | 405 µs | 9.58× faster | 201 µs | 61 µs | SVE UDOT |
| Polynomial product 64 × 64 → Int64List | 397 ns | 806 ns | 852 ns | 2.03× faster | 1.45 µs | 1.33 µs | NEON UDOT |
| Polynomial product 64 × 64 → Int32List | 390 ns | 497 ns | 593 ns | 1.27× faster | 1.45 µs | 754 ns | NEON UDOT |
| Polynomial product 256 × 256 → Int32List | 1.51 µs | 5.86 µs | 6.86 µs | 3.87× faster | 6.94 µs | 9.73 µs | NEON UDOT |
| Polynomial product 256 × 256 → Int64List | 1.55 µs | 12.5 µs | 13.4 µs | 8.06× faster | 6.94 µs | 19.1 µs | NEON UDOT |
| Polynomial product 1024 × 1024 → Int32List | 16.1 µs | 92.3 µs | 113 µs | 5.75× faster | 64.1 µs | 147 µs | NEON UDOT |
| Polynomial product 1024 × 1024 → Int64List | 16.3 µs | 199 µs | 223 µs | 12.2× faster | 64.1 µs | 300 µs | NEON UDOT |
| Polynomial product 4096 × 4096 → Int32List | 231 µs | 1.47 ms | 1.82 ms | 6.38× faster | 877 µs | 2.34 ms | SVE UDOT |
| Polynomial product 4096 × 4096 → Int64List | 232 µs | 3.2 ms | 3.58 ms | 13.8× faster | 877 µs | 4.8 ms | SVE UDOT |
| Byte matrix product 64 × 64, dot form | 2.78 µs | 9.91 µs | 29 µs | 3.57× faster | 24.2 µs | 35.4 µs | UMMLA |
| Byte matrix product 64 × 64, row form | 3.2 µs | 13.1 µs | 14 µs | 4.08× faster | 24.2 µs | 40.4 µs | UMMLA |
| Byte matrix product 256 × 256, dot form | 110 µs | 484 µs | 1.52 ms | 4.38× faster | 760 µs | 1.34 ms | UMMLA |
| Byte matrix product 256 × 256, row form | 120 µs | 907 µs | 934 µs | 7.54× faster | 760 µs | 1.61 ms | UMMLA |
| Byte matrix product 512 × 512, dot form | 792 µs | 4.09 ms | 11.8 ms | 5.17× faster | 5.71 ms | 9.74 ms | UMMLA |
| Byte matrix product 512 × 512, row form | 884 µs | 7.26 ms | 7.5 ms | 8.21× faster | 5.71 ms | 11.9 ms | UMMLA |
| FIR filter, 16 taps, 64K samples | 44 µs | 125 µs | 161 µs | 2.84× faster | – | 169 µs | SVE UDOT + USDOT |
| FIR filter, 16 taps, 1M samples | 754 µs | 2.49 ms | 2.8 ms | 3.31× faster | – | 3.19 ms | SVE UDOT + USDOT |
| 3 × 3 convolution, 256 × 256 bytes | 53 µs | 77.4 µs | 86.5 µs | 1.46× faster | – | 147 µs | SVE UDOT + USDOT |
| 3 × 3 convolution, 1024 × 1024 bytes | 813 µs | 1.48 ms | 1.65 ms | 1.82× faster | – | 1.92 ms | SVE UDOT + USDOT |
AWS Graviton4 (Neoverse V2)
| Loop | Raya | gcc 13 | clang 18 | Raya vs the faster C | Hand intrinsics | Raya without the kernels | Kernel |
|---|---|---|---|---|---|---|---|
| Byte dot product, 4K pairs | 122 ns | 1.44 µs | 1.09 µs | 8.95× faster | 700 ns | 218 ns | NEON UDOT |
| Byte dot product, 64K pairs | 1.91 µs | 23.4 µs | 17.6 µs | 9.22× faster | 11.6 µs | 3.31 µs | NEON UDOT |
| Byte dot product, 1M pairs | 38.4 µs | 376 µs | 298 µs | 7.76× faster | 186 µs | 68.4 µs | NEON UDOT |
| Polynomial product 64 × 64 → Int64List | 298 ns | 745 ns | 869 ns | 2.50× faster | 1.25 µs | 1.15 µs | NEON UDOT |
| Polynomial product 64 × 64 → Int32List | 286 ns | 465 ns | 473 ns | 1.63× faster | 1.25 µs | 653 ns | NEON UDOT |
| Polynomial product 256 × 256 → Int32List | 1.44 µs | 6.21 µs | 7.05 µs | 4.30× faster | 6.25 µs | 10.1 µs | NEON UDOT |
| Polynomial product 256 × 256 → Int64List | 1.49 µs | 11.6 µs | 13.8 µs | 7.80× faster | 6.25 µs | 15.9 µs | NEON UDOT |
| Polynomial product 1024 × 1024 → Int32List | 17.5 µs | 97 µs | 115 µs | 5.55× faster | 60 µs | 153 µs | NEON UDOT |
| Polynomial product 1024 × 1024 → Int64List | 17.6 µs | 185 µs | 223 µs | 10.5× faster | 60 µs | 247 µs | NEON UDOT |
| Polynomial product 4096 × 4096 → Int32List | 269 µs | 1.55 ms | 1.82 ms | 5.76× faster | 822 µs | 2.46 ms | NEON UDOT |
| Polynomial product 4096 × 4096 → Int64List | 272 µs | 2.98 ms | 3.55 ms | 11.0× faster | 822 µs | 3.94 ms | NEON UDOT |
| Byte matrix product 64 × 64, dot form | 2.4 µs | 9.15 µs | 23.7 µs | 3.81× faster | 17.7 µs | 27.5 µs | UMMLA |
| Byte matrix product 64 × 64, row form | 2.71 µs | 14.4 µs | 15.3 µs | 5.31× faster | 17.7 µs | 25.1 µs | UMMLA |
| Byte matrix product 256 × 256, dot form | 95.7 µs | 528 µs | 1.4 ms | 5.51× faster | 638 µs | 1.08 ms | UMMLA |
| Byte matrix product 256 × 256, row form | 106 µs | 800 µs | 1.04 ms | 7.52× faster | 638 µs | 1.4 ms | UMMLA |
| Byte matrix product 512 × 512, dot form | 722 µs | 4.17 ms | 11.7 ms | 5.77× faster | 4.96 ms | 7.88 ms | UMMLA |
| Byte matrix product 512 × 512, row form | 773 µs | 7.2 ms | 7.84 ms | 9.31× faster | 4.96 ms | 12.3 ms | UMMLA |
| FIR filter, 16 taps, 64K samples | 41.6 µs | 139 µs | 124 µs | 2.97× faster | – | 180 µs | NEON UDOT + USDOT |
| FIR filter, 16 taps, 1M samples | 739 µs | 2.82 ms | 3.04 ms | 3.82× faster | – | 3.59 ms | NEON UDOT + USDOT |
| 3 × 3 convolution, 256 × 256 bytes | 49.8 µs | 85.4 µs | 77.7 µs | 1.56× faster | – | 123 µs | NEON UDOT + USDOT |
| 3 × 3 convolution, 1024 × 1024 bytes | 798 µs | 1.67 ms | 1.81 ms | 2.09× faster | – | 2.22 ms | NEON UDOT + USDOT |
Intel Xeon Sapphire Rapids
| Loop | Raya | gcc 13 | clang 18 | Raya vs the faster C | Hand intrinsics | Raya without the kernels | Kernel |
|---|---|---|---|---|---|---|---|
| Byte dot product, 4K pairs | 97.2 ns | 862 ns | 572 ns | 5.89× faster | 8.02 µs | 386 ns | VPDPBUSD |
| Byte dot product, 64K pairs | 1.45 µs | 13.7 µs | 9.14 µs | 6.29× faster | 130 µs | 5.78 µs | VPDPBUSD |
| Byte dot product, 1M pairs | 34.5 µs | 222 µs | 147 µs | 4.26× faster | 2.11 ms | 94.5 µs | VPDPBUSD |
| Polynomial product 64 × 64 → Int64List | 250 ns | 860 ns | 732 ns | 2.93× faster | 10.4 µs | 1.37 µs | VPDPBUSD |
| Polynomial product 64 × 64 → Int32List | 231 ns | 669 ns | 626 ns | 2.71× faster | 10.4 µs | 765 ns | VPDPBUSD |
| Polynomial product 256 × 256 → Int32List | 762 ns | 6.41 µs | 4.03 µs | 5.29× faster | 128 µs | 9.71 µs | VPDPBUSD |
| Polynomial product 256 × 256 → Int64List | 825 ns | 13.4 µs | 8.15 µs | 9.87× faster | 128 µs | 19 µs | VPDPBUSD |
| Polynomial product 1024 × 1024 → Int32List | 6.91 µs | 102 µs | 60 µs | 8.69× faster | 1.93 ms | 148 µs | VPDPBUSD |
| Polynomial product 1024 × 1024 → Int64List | 7.11 µs | 211 µs | 125 µs | 17.6× faster | 1.93 ms | 292 µs | VPDPBUSD |
| Polynomial product 4096 × 4096 → Int32List | 94.6 µs | 1.61 ms | 1.04 ms | 11.0× faster | 28 ms | 2.37 ms | VPDPBUSD |
| Polynomial product 4096 × 4096 → Int64List | 96.9 µs | 3.4 ms | 2.07 ms | 21.4× faster | 28 ms | 4.67 ms | VPDPBUSD |
| Byte matrix product 64 × 64, dot form | 2.12 µs | 28.6 µs | 17.2 µs | 8.14× faster | 482 µs | 42.7 µs | AMX TDPBUUD |
| Byte matrix product 64 × 64, row form | 2.38 µs | 13.8 µs | 9.83 µs | 4.13× faster | 482 µs | 31 µs | AMX TDPBUUD |
| Byte matrix product 256 × 256, dot form | 35.2 µs | 1.78 ms | 917 µs | 26.0× faster | 30.5 ms | 1.92 ms | AMX TDPBUUD |
| Byte matrix product 256 × 256, row form | 42.2 µs | 875 µs | 664 µs | 15.7× faster | 30.5 ms | 1.63 ms | AMX TDPBUUD |
| Byte matrix product 512 × 512, dot form | 166 µs | 14.1 ms | 7.05 ms | 42.5× faster | 245 ms | 14.4 ms | AMX TDPBUUD |
| Byte matrix product 512 × 512, row form | 196 µs | 6.74 ms | 4.94 ms | 25.1× faster | 245 ms | 11.6 ms | AMX TDPBUUD |
| FIR filter, 16 taps, 64K samples | 22.5 µs | 106 µs | 95.8 µs | 4.26× faster | – | 165 µs | VPDPWSSD |
| FIR filter, 16 taps, 1M samples | 482 µs | 2.86 ms | 2.93 ms | 5.94× faster | – | 3.01 ms | VPDPWSSD |
| 3 × 3 convolution, 256 × 256 bytes | 31 µs | 69.7 µs | 63.4 µs | 2.05× faster | – | 125 µs | VPDPWSSD |
| 3 × 3 convolution, 1024 × 1024 bytes | 445 µs | 1.68 ms | 1.71 ms | 3.78× faster | – | 1.9 ms | VPDPWSSD |
Intel Xeon Ice Lake
| Loop | Raya | gcc 13 | clang 18 | Raya vs the faster C | Hand intrinsics | Raya without the kernels | Kernel |
|---|---|---|---|---|---|---|---|
| Byte dot product, 4K pairs | 135 ns | 887 ns | 596 ns | 4.43× faster | 12 µs | 476 ns | VPDPBUSD |
| Byte dot product, 64K pairs | 2.32 µs | 14.2 µs | 9.47 µs | 4.07× faster | 194 µs | 7.38 µs | VPDPBUSD |
| Byte dot product, 1M pairs | 65.5 µs | 228 µs | 152 µs | 2.33× faster | 3.1 ms | 135 µs | VPDPBUSD |
| Polynomial product 64 × 64 → Int64List | 348 ns | 885 ns | 564 ns | 1.62× faster | 15.8 µs | 1.71 µs | VPDPBUSD |
| Polynomial product 64 × 64 → Int32List | 333 ns | 583 ns | 553 ns | 1.66× faster | 15.8 µs | 1.01 µs | VPDPBUSD |
| Polynomial product 256 × 256 → Int32List | 1.17 µs | 6.59 µs | 3.49 µs | 2.98× faster | 199 µs | 12.7 µs | VPDPBUSD |
| Polynomial product 256 × 256 → Int64List | 1.25 µs | 13.7 µs | 7.8 µs | 6.25× faster | 199 µs | 23.7 µs | VPDPBUSD |
| Polynomial product 1024 × 1024 → Int32List | 13.8 µs | 104 µs | 63.9 µs | 4.63× faster | 3.03 ms | 192 µs | VPDPBUSD |
| Polynomial product 1024 × 1024 → Int64List | 14.2 µs | 218 µs | 124 µs | 8.79× faster | 3.03 ms | 381 µs | VPDPBUSD |
| Polynomial product 4096 × 4096 → Int32List | 192 µs | 1.67 ms | 1.01 ms | 5.26× faster | 43.7 ms | 3.06 ms | VPDPBUSD |
| Polynomial product 4096 × 4096 → Int64List | 194 µs | 3.49 ms | 1.99 ms | 10.3× faster | 43.7 ms | 6.22 ms | VPDPBUSD |
| Byte matrix product 64 × 64, dot form | 3.38 µs | 29.6 µs | 21.2 µs | 6.28× faster | 744 µs | 56.2 µs | VPDPBUSD |
| Byte matrix product 64 × 64, row form | 3.83 µs | 14.5 µs | 11 µs | 2.86× faster | 744 µs | 38.8 µs | VPDPBUSD |
| Byte matrix product 256 × 256, dot form | 89.6 µs | 1.83 ms | 1.07 ms | 11.9× faster | 46.9 ms | 2.46 ms | VPDPBUSD |
| Byte matrix product 256 × 256, row form | 101 µs | 965 µs | 763 µs | 7.55× faster | 46.9 ms | 2 ms | VPDPBUSD |
| Byte matrix product 512 × 512, dot form | 616 µs | 14.6 ms | 8.32 ms | 13.5× faster | 375 ms | 18.3 ms | VPDPBUSD |
| Byte matrix product 512 × 512, row form | 661 µs | 7.24 ms | 5.26 ms | 7.97× faster | 375 ms | 14.2 ms | VPDPBUSD |
| FIR filter, 16 taps, 64K samples | 29.5 µs | 118 µs | 91.5 µs | 3.10× faster | – | 213 µs | VPDPWSSD |
| FIR filter, 16 taps, 1M samples | 574 µs | 3.01 ms | 2.98 ms | 5.20× faster | – | 3.61 ms | VPDPWSSD |
| 3 × 3 convolution, 256 × 256 bytes | 41.9 µs | 86.2 µs | 69.8 µs | 1.67× faster | – | 157 µs | VPDPWSSD |
| 3 × 3 convolution, 1024 × 1024 bytes | 589 µs | 1.79 ms | 1.74 ms | 2.96× faster | – | 2.23 ms | VPDPWSSD |
AMD EPYC Zen 4
| Loop | Raya | gcc 13 | clang 18 | Raya vs the faster C | Hand intrinsics | Raya without the kernels | Kernel |
|---|---|---|---|---|---|---|---|
| Byte dot product, 4K pairs | 108 ns | 433 ns | 361 ns | 3.33× faster | 8.43 µs | 406 ns | VPDPBUSD |
| Byte dot product, 64K pairs | 1.24 µs | 6.86 µs | 5.74 µs | 4.63× faster | 134 µs | 6.18 µs | VPDPBUSD |
| Byte dot product, 1M pairs | 22.9 µs | 110 µs | 91.4 µs | 3.99× faster | 2.12 ms | 99.1 µs | VPDPBUSD |
| Polynomial product 64 × 64 → Int64List | 283 ns | 877 ns | 731 ns | 2.58× faster | 10.9 µs | 1.45 µs | VPDPBUSD |
| Polynomial product 64 × 64 → Int32List | 255 ns | 643 ns | 633 ns | 2.48× faster | 10.9 µs | 804 ns | VPDPBUSD |
| Polynomial product 256 × 256 → Int32List | 934 ns | 3.71 µs | 3.26 µs | 3.49× faster | 140 µs | 10.2 µs | VPDPBUSD |
| Polynomial product 256 × 256 → Int64List | 1e+03 ns | 7.44 µs | 6.21 µs | 6.21× faster | 140 µs | 19.9 µs | VPDPBUSD |
| Polynomial product 1024 × 1024 → Int32List | 9.89 µs | 52.8 µs | 49.8 µs | 5.03× faster | 2.11 ms | 155 µs | VPDPBUSD |
| Polynomial product 1024 × 1024 → Int64List | 10.3 µs | 120 µs | 96.1 µs | 9.32× faster | 2.11 ms | 308 µs | VPDPBUSD |
| Polynomial product 4096 × 4096 → Int32List | 136 µs | 873 µs | 795 µs | 5.83× faster | 31.2 ms | 2.45 ms | VPDPBUSD |
| Polynomial product 4096 × 4096 → Int64List | 137 µs | 2.03 ms | 1.72 ms | 12.5× faster | 31.2 ms | 4.98 ms | VPDPBUSD |
| Byte matrix product 64 × 64, dot form | 2.72 µs | 18.8 µs | 13.3 µs | 4.90× faster | 503 µs | 45.5 µs | VPDPBUSD |
| Byte matrix product 64 × 64, row form | 3 µs | 20.9 µs | 20.7 µs | 6.89× faster | 503 µs | 31.3 µs | VPDPBUSD |
| Byte matrix product 256 × 256, dot form | 91.4 µs | 980 µs | 526 µs | 5.75× faster | 32.9 ms | 2.01 ms | VPDPBUSD |
| Byte matrix product 256 × 256, row form | 96 µs | 663 µs | 632 µs | 6.58× faster | 32.9 ms | 1.7 ms | VPDPBUSD |
| Byte matrix product 512 × 512, dot form | 655 µs | 7.55 ms | 3.81 ms | 5.81× faster | 257 ms | 14.9 ms | VPDPBUSD |
| Byte matrix product 512 × 512, row form | 675 µs | 4.34 ms | 4.13 ms | 6.12× faster | 257 ms | 12.1 ms | VPDPBUSD |
| FIR filter, 16 taps, 64K samples | 23.2 µs | 72.5 µs | 62.8 µs | 2.71× faster | – | 165 µs | VPDPWSSD |
| FIR filter, 16 taps, 1M samples | 375 µs | 1.24 ms | 1.18 ms | 3.13× faster | – | 2.67 ms | VPDPWSSD |
| 3 × 3 convolution, 256 × 256 bytes | 31.1 µs | 58.1 µs | 42.9 µs | 1.38× faster | – | 133 µs | VPDPWSSD |
| 3 × 3 convolution, 1024 × 1024 bytes | 360 µs | 729 µs | 654 µs | 1.82× faster | – | 1.71 ms | VPDPWSSD |
Vector code the compiler writes itself
For two of the shapes, the compiler now writes the vector code itself, in place, with no call into the runtime:
- byte dot products,
s += a[i] * b[i], withaandbbothUint8Listor bothInt8List; - polynomial products of byte lists,
c[i + j] += a[i] * b[j], into anInt32List,Uint32List,Int64ListorUint64List.
How. The front end puts a marker call in front of the kernel call it already makes for these nests, and the compiler replaces the marker with one IL instruction that emits the whole nest as straight vector loops. The code path is picked when the program runs, from the CPU's features, so one executable runs on any CPU of its architecture:
- Arm: NEON
UDOT/SDOT. Polynomial products run as correlations over sliding 4-byte windows of the data. On Graviton3, dot products of 16K to 2M bytes use 256-bit SVEUDOT/SDOT, where it measured faster than NEON (and slower below and above that range). - x86: AVX-512 VNNI
VPDPBUSD, with one side moved to the other signedness (an XOR with0x80) and 128 times the other side's sum added back. CPUs with AVX2 but no AVX-512 VNNI get an AVX2 dot product; their polynomial products still go to the kernel call.
Exactness. Products are added in 32-bit lanes, and range analysis over the element types bounds every lane before it can overflow: a byte product is at most 65,025 (unsigned) or 16,384 in magnitude (signed). Dot products move their 32-bit lanes into 64-bit sums at least every 16,384 steps; polynomial products take at most 256 terms per pass (256 × 65,025 < 2³¹) before adding to the destination. When the CPU has no usable path, a list isn't what the code expects, an index is out of range, or the destination overlaps a source, the code writes nothing; then the kernel call and, after it, the loops run exactly as before. raya_nest_codegen_test.ray checks both shapes against the plain loops (random and edge values, every length up to 700 and long ones across every block boundary, views, out-of-range bounds, overlapping destinations) for each code path and with the kernels off, on all five CPUs.
What it gains. The kernel call costs a few tens of nanoseconds (argument checks, a native transition, a handle per list), which is most of the time for small nests. In place, dot products of up to 4K bytes run 1.7 to 5.8 times faster than through the kernel, and polynomial products of up to 64 terms 1.4 to 3.5 times faster. Large nests are level with the kernel (within about 2%, at most 2.3% slower) or faster (up to 1.7 times on Graviton4).
Where it loses. 256 × 256 polynomial products on Ice Lake are 5 to 7% slower than the kernel call. A 16 × 16 product into an Int64List on EPYC Zen 4 is 0.87× clang, the one loop and CPU where C is faster: fixed costs dominate a nest of 256 products. A few large cases are 1–2.3% behind the kernel.
The compiler's own code against the faster of gcc and clang (more than 1× is a win for Raya):
| Loop | Graviton3 | Graviton4 | Sapphire Rapids | Ice Lake | EPYC Zen 4 |
|---|---|---|---|---|---|
| Byte dot product, 256 pairs | 5.22× | 5.36× | 3.26× | 2.63× | 2.18× |
| Byte dot product, 1K pairs | 12.2× | 9.80× | 7.47× | 6.25× | 4.88× |
| Byte dot product, 4K pairs | 17.9× | 13.4× | 9.35× | 7.84× | 6.60× |
| Byte dot product, 64K pairs | 13.1× | 9.50× | 6.31× | 4.39× | 4.79× |
| Byte dot product, 1M pairs | 10.6× | 7.88× | 4.29× | 2.46× | 4.01× |
| Polynomial product 16 × 16 → Int32List | 1.51× | 1.59× | 1.08× | 1.15× | 1.15× |
| Polynomial product 16 × 16 → Int64List | 1.04× | 1.13× | 1.56× | 1.13× | 0.87× |
| Polynomial product 64 × 64 → Int32List | 3.27× | 3.77× | 5.05× | 2.44× | 3.88× |
| Polynomial product 64 × 64 → Int64List | 4.85× | 5.58× | 5.05× | 2.30× | 4.01× |
| Polynomial product 256 × 256 → Int32List | 5.33× | 7.19× | 6.38× | 2.76× | 3.71× |
| Polynomial product 256 × 256 → Int64List | 11.1× | 12.9× | 11.8× | 5.87× | 6.79× |
| Polynomial product 1024 × 1024 → Int32List | 6.15× | 8.09× | 9.42× | 4.96× | 5.58× |
| Polynomial product 1024 × 1024 → Int64List | 13.1× | 15.3× | 18.9× | 9.48× | 10.3× |
| Polynomial product 4096 × 4096 → Int32List | 6.36× | 8.35× | 11.8× | 5.63× | 6.36× |
| Polynomial product 4096 × 4096 → Int64List | 13.6× | 15.7× | 22.0× | 10.6× | 13.2× |
Geometric mean over the 15 loops, per CPU: Graviton3 6.5×, Graviton4 6.8×, Sapphire Rapids 6.3×, Ice Lake 3.8×, EPYC Zen 4 4.2×.
Time per call, one thread, best of five blocks of at least 60 ms, each implementation checked against a scalar reference first. "Kernel call" is the same program with --no-raya-nest-codegen. C as above. Measurements in benchmarks/RayaIntVec/results/2026-12-01-codegen/.
AWS Graviton3 (Neoverse V1), compiler's own code
| Loop | Compiler's own code | Kernel call | gcc 13 | clang 18 | vs the faster C | vs the kernel call |
|---|---|---|---|---|---|---|
| Byte dot product, 256 pairs | 14.4 ns | 75.7 ns | 75 ns | 99.9 ns | 5.22× | 5.26× |
| Byte dot product, 1K pairs | 30.4 ns | 92.4 ns | 372 ns | 401 ns | 12.2× | 3.04× |
| Byte dot product, 4K pairs | 87 ns | 163 ns | 1.56 µs | 1.59 µs | 17.9× | 1.87× |
| Byte dot product, 64K pairs | 1.94 µs | 2.12 µs | 25.3 µs | 25.3 µs | 13.1× | 1.10× |
| Byte dot product, 1M pairs | 38.3 µs | 41.8 µs | 405 µs | 405 µs | 10.6× | 1.09× |
| Polynomial product 16 × 16 → Int32List | 75 ns | 266 ns | 113 ns | 119 ns | 1.51× | 3.54× |
| Polynomial product 16 × 16 → Int64List | 78.6 ns | 260 ns | 82 ns | 82.6 ns | 1.04× | 3.30× |
| Polynomial product 64 × 64 → Int32List | 152 ns | 369 ns | 497 ns | 592 ns | 3.27× | 2.43× |
| Polynomial product 64 × 64 → Int64List | 166 ns | 369 ns | 805 ns | 856 ns | 4.85× | 2.23× |
| Polynomial product 256 × 256 → Int32List | 1.1 µs | 1.51 µs | 5.85 µs | 6.86 µs | 5.33× | 1.38× |
| Polynomial product 256 × 256 → Int64List | 1.13 µs | 1.55 µs | 12.5 µs | 13.4 µs | 11.1× | 1.37× |
| Polynomial product 1024 × 1024 → Int32List | 15 µs | 16.1 µs | 92.3 µs | 114 µs | 6.15× | 1.07× |
| Polynomial product 1024 × 1024 → Int64List | 15.3 µs | 16.3 µs | 200 µs | 223 µs | 13.1× | 1.07× |
| Polynomial product 4096 × 4096 → Int32List | 231 µs | 230 µs | 1.47 ms | 1.81 ms | 6.36× | 1.00× |
| Polynomial product 4096 × 4096 → Int64List | 235 µs | 232 µs | 3.2 ms | 3.57 ms | 13.6× | 0.99× (slower) |
AWS Graviton4 (Neoverse V2), compiler's own code
| Loop | Compiler's own code | Kernel call | gcc 13 | clang 18 | vs the faster C | vs the kernel call |
|---|---|---|---|---|---|---|
| Byte dot product, 256 pairs | 11.5 ns | 62.5 ns | 61.7 ns | 62 ns | 5.36× | 5.44× |
| Byte dot product, 1K pairs | 27.4 ns | 78.8 ns | 337 ns | 268 ns | 9.80× | 2.88× |
| Byte dot product, 4K pairs | 81.8 ns | 149 ns | 1.44 µs | 1.09 µs | 13.4× | 1.82× |
| Byte dot product, 64K pairs | 1.86 µs | 1.92 µs | 23.5 µs | 17.6 µs | 9.50× | 1.04× |
| Byte dot product, 1M pairs | 39.1 µs | 38.2 µs | 376 µs | 308 µs | 7.88× | 0.98× (slower) |
| Polynomial product 16 × 16 → Int32List | 62 ns | 183 ns | 98.5 ns | 104 ns | 1.59× | 2.95× |
| Polynomial product 16 × 16 → Int64List | 64.8 ns | 190 ns | 73.5 ns | 91.2 ns | 1.13× | 2.94× |
| Polynomial product 64 × 64 → Int32List | 124 ns | 291 ns | 466 ns | 484 ns | 3.77× | 2.35× |
| Polynomial product 64 × 64 → Int64List | 134 ns | 303 ns | 746 ns | 870 ns | 5.58× | 2.26× |
| Polynomial product 256 × 256 → Int32List | 864 ns | 1.45 µs | 6.21 µs | 7.05 µs | 7.19× | 1.68× |
| Polynomial product 256 × 256 → Int64List | 898 ns | 1.5 µs | 11.6 µs | 13.8 µs | 12.9× | 1.67× |
| Polynomial product 1024 × 1024 → Int32List | 12 µs | 17 µs | 97 µs | 115 µs | 8.09× | 1.42× |
| Polynomial product 1024 × 1024 → Int64List | 12.3 µs | 17.9 µs | 188 µs | 223 µs | 15.3× | 1.46× |
| Polynomial product 4096 × 4096 → Int32List | 186 µs | 258 µs | 1.55 ms | 1.82 ms | 8.35× | 1.39× |
| Polynomial product 4096 × 4096 → Int64List | 190 µs | 260 µs | 2.98 ms | 3.55 ms | 15.7× | 1.37× |
Intel Xeon Sapphire Rapids, compiler's own code
| Loop | Compiler's own code | Kernel call | gcc 13 | clang 18 | vs the faster C | vs the kernel call |
|---|---|---|---|---|---|---|
| Byte dot product, 256 pairs | 11.3 ns | 58.4 ns | 55.3 ns | 36.9 ns | 3.26× | 5.16× |
| Byte dot product, 1K pairs | 19.8 ns | 68.3 ns | 222 ns | 148 ns | 7.47× | 3.45× |
| Byte dot product, 4K pairs | 62.5 ns | 106 ns | 879 ns | 584 ns | 9.35× | 1.70× |
| Byte dot product, 64K pairs | 1.48 µs | 1.53 µs | 14.1 µs | 9.36 µs | 6.31× | 1.03× |
| Byte dot product, 1M pairs | 35.6 µs | 34.9 µs | 230 µs | 153 µs | 4.29× | 0.98× (slower) |
| Polynomial product 16 × 16 → Int32List | 83.5 ns | 175 ns | 115 ns | 90.5 ns | 1.08× | 2.09× |
| Polynomial product 16 × 16 → Int64List | 84.8 ns | 176 ns | 133 ns | 133 ns | 1.56× | 2.08× |
| Polynomial product 64 × 64 → Int32List | 130 ns | 238 ns | 696 ns | 654 ns | 5.05× | 1.84× |
| Polynomial product 64 × 64 → Int64List | 152 ns | 254 ns | 882 ns | 769 ns | 5.05× | 1.67× |
| Polynomial product 256 × 256 → Int32List | 672 ns | 773 ns | 6.57 µs | 4.29 µs | 6.38× | 1.15× |
| Polynomial product 256 × 256 → Int64List | 718 ns | 850 ns | 13.6 µs | 8.5 µs | 11.8× | 1.18× |
| Polynomial product 1024 × 1024 → Int32List | 6.76 µs | 7.09 µs | 103 µs | 63.7 µs | 9.42× | 1.05× |
| Polynomial product 1024 × 1024 → Int64List | 7.06 µs | 7.36 µs | 216 µs | 134 µs | 18.9× | 1.04× |
| Polynomial product 4096 × 4096 → Int32List | 92 µs | 97 µs | 1.65 ms | 1.08 ms | 11.8× | 1.05× |
| Polynomial product 4096 × 4096 → Int64List | 98.2 µs | 99 µs | 3.44 ms | 2.17 ms | 22.0× | 1.01× |
Intel Xeon Ice Lake, compiler's own code
| Loop | Compiler's own code | Kernel call | gcc 13 | clang 18 | vs the faster C | vs the kernel call |
|---|---|---|---|---|---|---|
| Byte dot product, 256 pairs | 14.2 ns | 79.4 ns | 55.7 ns | 37.2 ns | 2.63× | 5.60× |
| Byte dot product, 1K pairs | 23.7 ns | 87.3 ns | 222 ns | 148 ns | 6.25× | 3.69× |
| Byte dot product, 4K pairs | 76 ns | 138 ns | 887 ns | 596 ns | 7.84× | 1.82× |
| Byte dot product, 64K pairs | 2.16 µs | 2.31 µs | 14.2 µs | 9.47 µs | 4.39× | 1.07× |
| Byte dot product, 1M pairs | 62 µs | 63.9 µs | 228 µs | 152 µs | 2.46× | 1.03× |
| Polynomial product 16 × 16 → Int32List | 103 ns | 244 ns | 119 ns | 174 ns | 1.15× | 2.37× |
| Polynomial product 16 × 16 → Int64List | 116 ns | 244 ns | 135 ns | 131 ns | 1.13× | 2.11× |
| Polynomial product 64 × 64 → Int32List | 226 ns | 342 ns | 583 ns | 553 ns | 2.44× | 1.51× |
| Polynomial product 64 × 64 → Int64List | 246 ns | 350 ns | 886 ns | 565 ns | 2.30× | 1.43× |
| Polynomial product 256 × 256 → Int32List | 1.27 µs | 1.18 µs | 6.59 µs | 3.49 µs | 2.76× | 0.93× (slower) |
| Polynomial product 256 × 256 → Int64List | 1.33 µs | 1.26 µs | 13.7 µs | 7.82 µs | 5.87× | 0.95× (slower) |
| Polynomial product 1024 × 1024 → Int32List | 13.1 µs | 13.8 µs | 105 µs | 64.9 µs | 4.96× | 1.06× |
| Polynomial product 1024 × 1024 → Int64List | 13.6 µs | 14.2 µs | 224 µs | 129 µs | 9.48× | 1.04× |
| Polynomial product 4096 × 4096 → Int32List | 183 µs | 192 µs | 1.68 ms | 1.03 ms | 5.63× | 1.05× |
| Polynomial product 4096 × 4096 → Int64List | 190 µs | 194 µs | 3.49 ms | 2.03 ms | 10.6× | 1.02× |
AMD EPYC Zen 4, compiler's own code
| Loop | Compiler's own code | Kernel call | gcc 13 | clang 18 | vs the faster C | vs the kernel call |
|---|---|---|---|---|---|---|
| Byte dot product, 256 pairs | 10.5 ns | 60.8 ns | 28.3 ns | 22.9 ns | 2.18× | 5.79× |
| Byte dot product, 1K pairs | 18.4 ns | 76.4 ns | 109 ns | 89.7 ns | 4.88× | 4.16× |
| Byte dot product, 4K pairs | 54.9 ns | 120 ns | 433 ns | 363 ns | 6.60× | 2.18× |
| Byte dot product, 64K pairs | 1.18 µs | 1.27 µs | 6.86 µs | 5.67 µs | 4.79× | 1.08× |
| Byte dot product, 1M pairs | 22.8 µs | 22.9 µs | 110 µs | 91.5 µs | 4.01× | 1.00× |
| Polynomial product 16 × 16 → Int32List | 89.4 ns | 182 ns | 145 ns | 102 ns | 1.15× | 2.04× |
| Polynomial product 16 × 16 → Int64List | 97 ns | 188 ns | 107 ns | 84.1 ns | 0.87× (slower) | 1.94× |
| Polynomial product 64 × 64 → Int32List | 159 ns | 258 ns | 641 ns | 617 ns | 3.88× | 1.62× |
| Polynomial product 64 × 64 → Int64List | 179 ns | 282 ns | 874 ns | 717 ns | 4.01× | 1.58× |
| Polynomial product 256 × 256 → Int32List | 883 ns | 954 ns | 3.7 µs | 3.28 µs | 3.71× | 1.08× |
| Polynomial product 256 × 256 → Int64List | 916 ns | 1 µs | 7.44 µs | 6.21 µs | 6.79× | 1.09× |
| Polynomial product 1024 × 1024 → Int32List | 8.87 µs | 10 µs | 52.7 µs | 49.6 µs | 5.58× | 1.13× |
| Polynomial product 1024 × 1024 → Int64List | 9.23 µs | 10.3 µs | 126 µs | 95.3 µs | 10.3× | 1.12× |
| Polynomial product 4096 × 4096 → Int32List | 125 µs | 136 µs | 856 µs | 795 µs | 6.36× | 1.09× |
| Polynomial product 4096 × 4096 → Int64List | 130 µs | 137 µs | 2.03 ms | 1.72 ms | 13.2× | 1.06× |
Where it doesn't apply
- Other shapes run as written. A nest with an
ifother than the zero-factorcontinue, a bound that changes inside the nest, an index that isn't linear (a[i * i],a[idx[i]]), or two products in one body is left to the vectoriser and the scalar loop. - Element types. The data side must be bytes (
Uint8List); taps may beUint8List,Int8ListorInt16List; matrix products are byte by byte; dot products are byte by byte (Int8Listtoo: on Arm through the kernels, and on both Arm and x86 through the compiler's own code). Wider operands, such asInt64Listcounts, use the vectoriser. - CPUs. Kernels need AVX-512 with VNNI on x86 and the dot-product instructions on Arm (Graviton2 and later, Apple M1 and later). Matrix products and signed taps on Arm also need
I8MM(Graviton3 and later). Byte dot products also run on x86 CPUs with AVX2 only, through the compiler's own AVX2 code. On other CPUs the call returns at once and the loops run as written. - Small work. For matrix products, FIR filters and 2-D convolutions, the call and its checks cost a few tens of nanoseconds, so a nest of a few hundred multiply-adds gains little. Dot and polynomial products no longer pay that cost.
- Ahead-of-time only. The pass runs in AOT builds (
raya compile exe,aot-snapshot), not in the JIT.
Reproduce
Everything is in the repository, under benchmarks/RayaIntVec/:
raya compile exe benchmarks/RayaIntVec/raya/intvec_bench.ray -o intvec_bench
./intvec_bench poly 4096 now
gcc -O3 -march=native -o intvec_bench_c benchmarks/RayaIntVec/c/intvec_bench.c && ./intvec_bench_c poly 4096 gcc
clang -O3 -march=native -o intvec_bench_c benchmarks/RayaIntVec/c/intvec_bench.c && ./intvec_bench_c poly 4096 clang
Cases: dot, poly, maxel, fir, conv2d, each with a size. Each prints one JSON line per implementation. The kernels alone, without the VM: clang++ -O2 -std=c++17 -I runtime runtime/vm/raya_nest_kernels.cc benchmarks/RayaIntVec/kernels/nest_kernels_test.cc -o nest_test, then ./nest_test test (exactness, every family this CPU has) or ./nest_test bench. The measurements on this page are in benchmarks/RayaIntVec/results/2026-12-01-nest/.
Details
Flags. --no-raya-nest-kernels (a VM flag) makes every call return false, so the loops run as written. -Draya.nest_kernels=false at compile time leaves the program without the calls. @pragma('raya:no-nest-kernel') on a function or method keeps the pass out of it. --trace-raya-nest prints, for each call, the kernel that ran or why the loops ran instead. --raya-nest-isa=N caps the kernel family (0 none; Arm 1 dot product, 2 I8MM, 3 SVE; x86 11 AVX-512 VNNI, 12 AMX) and --raya-nest-widest uses the widest kernel at every size; both are for tests. For the compiler's own code: --no-raya-nest-codegen (a VM flag) sends dot and polynomial nests to the kernels again; --raya-nest-codegen-isa=<mask> limits its code paths (tests: Arm 1 NEON, 2 SVE; x86 256 AVX2, 512 AVX-512 VNNI); --no-raya-nest-codegen-compile (gen_snapshot) and -Draya.nest_codegen=false (gen_kernel) leave the code out.
Shapes the runtime has kernels for. After loops of one iteration are dropped and loops are flipped so that unit steps are +1: a matrix product, dst[i, j] (+)= Σk A[i, k] · B[k, j] with any strides, written to a row-major or column-major destination; a 1-D or 2-D correlation, dst[oy, ox] += Σ w[ty, tx] · x[oy, ty, ox + tx] with the taps forward or reversed and any row strides; and a full 1-D convolution, dst[p + q] += a[p] · b[q], which the runtime turns into a correlation with the taps reversed and the data zero-padded in scratch memory, skipping the taps that only meet padding.
Also in this change. fillRange on the VM's integer typed lists now runs in native code (it was a loop that dispatched every store), so the zeroing before an accumulating nest costs what memset costs.
Next. The same approach, one shape at a time, each tested against the scalar loops the same way:
- Matrix products (row form and dot form) in the compiler's own code: Arm
UMMLA/SMMLAregister blocks, x86VPDPBUSDregister blocks, then AMX-INT8 tiles on Sapphire Rapids. - FIR filters and 2-D convolutions with
int8andint16taps (USDOT,VPDPWSSD), and the AVX2 polynomial product. - General integer loops: 256-bit and 512-bit lanes for the compiler's integer vectoriser (today 128-bit), so element-wise work and reductions that are not one of these shapes get the full vector width too.