Unlike scalar operations, we can perform vector operations on
element types that are smaller than the native integer types. We
type-promote scalar operations if they are smaller than a native
type (e.g., i8 arithmetic is promoted to i32 arithmetic on Arm
targets). This patch detects and removes type-promotions within the
reduction detection framework, enabling the vectorization of small
size reductions.
In the legality phase, we look through the ANDs and extensions that
InstCombine creates during promotion, keeping track of the smaller
type. In the profitability phase, we use the smaller type and
ignore the ANDs and extensions in the cost model. Finally, in the
code generation phase, we truncate the result of the reduction to
allow InstCombine to rewrite the entire expression in the smaller
type.
This fixes PR21369.
What would a non-arithmetic kind be? I'm not sure I understand this.