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

            Bug ID: 122885
           Summary: bool reduction fails to vectorize with masked loop
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

For reductions we require to mask out inactive lanes, even for bool &.  But
with AVX512 there's no masked kand operation.  Instead we can use bool
operations with the loop mask to emulate a masked operation.

Found with the testcase from PR122873

char *b;
bool c(int l) {
  bool d = true;
  for (int a = 0; a < l; a++)
    if (b[a])
      d = false;
  return d;
}

t.c:4:21: note:   ==> examining statement: _13 = _12 & d_14;
t.c:4:21: note:   vect_is_simple_use: operand _4 == 0, type of def: internal
t.c:4:21: note:   vect_is_simple_use: operand d_14 = PHI <_13(6), 1(5)>, type
of def: reduction
t.c:4:21: missed:   can't use a fully-masked loop because no conditional
operation is available.

Reply via email to