control-flowThe loop body branches
Reported by --explain after a verdict.
mettle explain control-flow
The body has a nested loop or a data-dependent if. Lanes execute in lockstep, so a branch that goes one way for lane 3 and the other way for lane 4 has no single instruction to be.
Note the compiler already if-converts short branches into masked arithmetic where it can (see if-converted). This code fires when the branch was too big or too effectful for that.
Fixes
hoist the condition out when it does not depend on the index
replace a small
ifwith arithmetic:x = c * a + (1 - c) * bsplit one loop into two, each with a straight-line body
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
- early-exitThe loop can leave before its trip count
- int16-elements16-bit integer elements have no kernel
- int64-elements64-bit integer elements have no kernel