https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122598
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
CC| |andi-gcc at firstfloor dot org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the problem is that while for unconditional shifts we have separate
{ashl,ashr,lshr,rotl,rotr}_optab and v{ashl,ashr,lshr,rotl,rotr}_optab where
the former is for scalar operations and vector operations with scalar count and
the latter for vector operations with vector count, for the conditional one
there is just IFN_ASHL and IFN_ASHR which covers everything, i.e. both scalar
and vector counts (and any scalar and any vector counts, not just a subset of
those).
typedef char V __attribute__ ((vector_size (64)));
V
bar (V v)
{
V a = v >> 5;
return (V) {} < v ? v : a;
}
ICEs too with -O -mavx512f -mgfni, this time not because the vgf2p8affineqb
insn couldn't handle it, but because it expects a vector with the same counts
like (V)
{5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5}
instead of a scalar 5.
Unfortunately the cond_ashl/cond_ashr optabs aren't conditional, the generic
code doesn't have a fallback for this, so the pattern must always succeed.
And expanding the conditional left/right shift, scalar or vector in the
V*[SD]Imode case isn't that hard, but handling arbitrary V*[QH]Imode by
V*[QH]Imode shifts would be a nightmare.
So perhaps it might be better to drop the cond_{ashr,ashl,lshr}v*[qh]i optabs
and let combine merge a conditional move with the shifts and for
cond_{ashr,ashl,lshr}v*[sd]i make sure they can expand any count?
Actually
;; ../../gcc/config/i386/sse.md: 29296
(define_expand ("cond_ashlv16si")
[
(set (match_operand:V16SI 0 ("register_operand") (""))
(vec_merge:V16SI (ashift:V16SI (match_operand:V16SI 2
("register_operand") (""))
(match_operand:V16SI 3
("nonimmediate_or_const_vec_dup_operand") ("")))
(match_operand:V16SI 4 ("nonimm_or_0_operand") (""))
(match_operand:HI 1 ("register_operand") (""))))
] ("TARGET_AVX512F") ("{
most likely handles any kind, maybe_legitimize_operand can handle broadcasting
of a scalar to vector.