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

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
------------cut ------------
/* Function vect_is_simple_reduction

   (1) Detect a cross-iteration def-use cycle that represents a simple
   reduction computation.  We look for the following pattern:

   loop_header:
     a1 = phi < a0, a2 >
     a3 = ...
     a2 = operation (a3, a1)

   or

   a3 = ...
   loop_header:
     a1 = phi < a0, a2 >
     a2 = operation (a3, a1)

   such that:
   1. operation is commutative and associative and it is safe to
      change the order of the computation
   2. no uses for a2 in the loop (a2 is used out of the loop)
   3. no uses of a1 in the loop besides the reduction operation
---------end------------------


----dump vect-------
  <bb 3> [local count: 955630225]:
  # maxInt_19 = PHI <maxInt_7(8), maxInt_14(18)>
  # maxIndex_20 = PHI <maxIndex_9(8), 0(18)>
  # i_24 = PHI <i_18(8), 1(18)>
  _1 = (long unsigned int) i_24;
  _2 = _1 * 4;
  _3 = src_13(D) + _2;
  _4 = *_3;
  maxInt_7 = MAX_EXPR <_4, maxInt_19>; ------ reduction operation
  maxIndex_9 = _4 <= maxInt_19 ? maxIndex_20 : i_24; --- another use here.
  i_18 = i_24 + 1;
  if (n_15(D) > i_18)
----dump end---------

For the case in the PR, there's 2 uses for a1(maxInt_19), one in reduction
operation(MAX_EXPR <_4, maxInt_19>), another in 4 <= maxInt_19 ? maxIndex_20 :
i_24), and it failed.

Reply via email to