Mettle

clamp-storeA value clamped or selected before it is stored

Reported by --explain after a verdict.

mettle explain clamp-store

if (v > hi) { v = hi; } before a[i] = v is a clamp, and over int32 elements it vectorizes: the branch becomes vpminsd or vpmaxsd, or a lane select when the arms are not the two compared values. A chain of them, including the one an inlined helper's early returns leave behind, folds the same way.

This code fires when that conversion did not carry the loop. Two things stop it: float32 and float64 elements, which have no select kernel yet, and a nest deep enough that the values live at once outnumber the ymm registers the kernel has, which is six for an int32 map. Three levels of if/else over distinct expressions is past that.

Splitting the deepest arm into its own loop is what usually helps.

Related