https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125060
--- Comment #1 from Jeevitha <jeevitha at gcc dot gnu.org> ---
The V1TI vector comparison support was added to the rs6000 backend through
VEC_IC:
(define_mode_iterator VEC_IC [V16QI V8HI V4SI V2DI (V1TI "TARGET_POWER10")])
(define_mode_iterator VEC_I [V16QI V8HI V4SI V2DI])
However, V1TI was not added to the vcond_mask pattern, which uses VEC_I:
;; Same mode for condition true/false values and predicate operand.
(define_expand "vcond_mask_<mode><mode>"
[(match_operand:VEC_I 0 "vint_operand")
(match_operand:VEC_I 1 "vint_operand")
(match_operand:VEC_I 2 "vint_operand")
(match_operand:VEC_I 3 "vint_operand")]
"VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
{
emit_insn (gen_vector_select_<mode> (operands[0], operands[2], operands[1],
operands[3]));
DONE;
})
Therefore, there is no vcond_mask_v1tiv1ti pattern.
For example, consider the following testcase:
#include <altivec.h>
__vector __bool __int128
test_eq (__vector __int128 x, __vector __int128 y)
{
return x != y;
}
Before the vector-lowering change, the result is represented as a vector
conditional expression:
vector(1) <signed-boolean:128> _1;
__vector __bool __int128 _4;
_1 = x_2(D) != y_3(D);
_4 = VEC_COND_EXPR <_1, { -1 }, { 0 }>;
return _4;
However, with commit f40010c198f, the VEC_COND_EXPR is lowered to a scalar
sequence in veclower:
vector(1) <signed-boolean:128> _1;
__vector __bool __int128 _4;
<signed-boolean:128> _6;
_Bool _7;
__int128 _8;
__int128 _9;
_1 = x_2(D) != y_3(D);
_6 = VIEW_CONVERT_EXPR<<signed-boolean:128>>(_1);
_7 = _6 != 0;
_8 = (__int128) _7;
_9 = -_8;
_4 = {_9};
return _4;
The reason is that, for the V1TI case, the generic vector lowering checks
whether the vector conditional expression can be expanded:
expand_vec_cond_expr_p
For:
VEC_COND_EXPR (_1, {-1}, {0})
expand_vec_cond_expr_p returns false because the rs6000 backend does not have:
vcond_mask_v1tiv1ti
Since the vector conditional cannot be expanded, veclower scalarizes the
operation. This results in the additional scalar operations shown above instead
of keeping the result as a vector mask.