Mettle

predicated-countAn accumulator updated only on the taken arm

Reported by --explain after a verdict.

mettle explain predicated-count

Over int32 elements, if (a[i] > t) { c = c + 1; } and if (a[i] < 0) { s = s + a[i]; } both vectorize: the comparison already holds 0 or 1, so the compiler multiplies the addend by it and the body becomes straight line.

This code fires when that rewrite does not apply. Three shapes it will not take:

Related