store-only-fillFill loop the fill kernel could not claim
Reported by --explain after a verdict.
mettle explain store-only-fill
The loop writes the same value over and over, which is the fill shape, but one of the kernel's requirements was not met. The remark names which, because the answer differs:
Several stores in one body. The kernel fills one region per loop. Split it into one loop per destination and each becomes a kernel.
1-byte elements. The kernel covers 2, 4 and 8 bytes. This is a gap in the compiler; there is nothing to change in the loop.
A stack array as the destination.
a[i]on a local array recomputes the array's address every iteration, and the kernel indexes off one invariant base. Bind it once and write through the pointer:var p: float32* = &a[0]; for i in 0..n { p[i] = 1.0; }The generated code is the same either way; only the shape the recognizer sees changes.
An address the kernel cannot follow. It handles
a[i],a[c + i]withcinvariant, and a pointer walked by a constant stride. Lift the invariant part of the index into a base pointer before the loop.
Related
- call-in-bodyThe loop body calls a function
- extern-call-in-bodyThe loop body calls an external function
- indirect-callThe loop body calls through a function pointer
- alloc-in-bodyThe loop body allocates
- inline-asmThe loop body contains inline assembly
- control-flowThe loop body branches
- early-exitThe loop can leave before its trip count
- int16-elements16-bit integer elements have no kernel