https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96481

            Bug ID: 96481
           Summary: SLP fail to vectorize VEC_COND_EXPR pattern.
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

testcase not vectorized:
-----
#include <x86intrin.h>

inline unsigned opt(unsigned a, unsigned b, unsigned c, unsigned d) {
    return a > b ? c : d;
}

void opt( unsigned * __restrict dst, const unsigned *pa, const unsigned *pb,
        const unsigned *pc, const unsigned  *pd )
{

     *dst++ = opt(*pa++, *pb++, *pc++, *pd++);
     *dst++ = opt(*pa++, *pb++, *pc++, *pd++);
     *dst++ = opt(*pa++, *pb++, *pc++, *pd++);
     *dst++ = opt(*pa++, *pb++, *pc++, *pd++);
}
----


testcase successfully vectorized:

----
inline unsigned opt(unsigned a, unsigned b, unsigned c, unsigned d) {
    return a > b ? c : d;
}

void opt( unsigned * __restrict dst, const unsigned *pa, const unsigned *pb,
        const unsigned *pc, const unsigned  *pd )
{
    for (int i = 0; i != 4; i++)
     *dst++ = opt(*pa++, *pb++, *pc++, *pd++);
}
----

llvm can handle both case
refer to https://godbolt.org/z/jYoPxT

Reply via email to