variable-shiftA shift by a distance read at run time
Reported by --explain after a verdict.
mettle explain variable-shift
The kernels carry a shift only when the distance is written in the source. A distance the loop reads has no kernel, in either direction:
b[i] = a[i] >> k; // `k` a parameter or a variable
b[i] = a[i] << k;
Both stay scalar. A constant distance vectorizes:
b[i] = a[i] >> 8;
There is no source rewrite that reaches a kernel while the distance stays a run-time value, so this is a gap in the compiler rather than a problem with the loop. Splitting into one loop per distance works when the distances are few and known.
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