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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The vectorizer does not like

  <bb 3> [local count: 955630224]:
  # best_i_25 = PHI <best_i_11(8), best_i_16(D)(18)>
  # best_26 = PHI <best_13(8), 0(18)>
  # i_27 = PHI <i_20(8), 0(18)>
  _1 = (long unsigned int) i_27;
  _2 = _1 * 4;
  _3 = data_18(D) + _2;
  _4 = *_3;
  best_i_11 = _4 <= best_26 ? best_i_25 : i_27;
  best_13 = MAX_EXPR <_4, best_26>;
  i_20 = i_27 + 1;
  if (n_17(D) > i_20)

because for the best MAX reduction we have an additional use of the
reduction value in the index reduction.  This combination isn't
magically supported even though in isolation both cases are.

t.c:4:5: note:   Analyze phi: best_26 = PHI <best_13(8), 0(18)>
t.c:4:5: missed:   reduction used in loop.
t.c:4:5: missed:   Unknown def-use cycle pattern.
t.c:4:5: note:   Analyze phi: best_i_25 = PHI <best_i_11(8), best_i_16(D)(18)>
t.c:4:5: note:   detected reduction: need to swap operands: best_i_11 = _4 >
best_26 ? i_27 : best_i_25;
t.c:4:5: note:   Detected reduction.

if we'd been lucky and had analyzed best_i_25 before best_26 then we could
probably special-case the case of "reduction used in loop" when that appears
in other reductions.  In general that's of course still not valid I think.

Alternatively the reduction operation could be combined somehow via
pattern detection.

Reply via email to