This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR33299 (vectorizer wrong code)


Hi,

When vectorizing reductions we need to replace the uses of the original
reduction variable with the new (vectorized) one. To do this we look for
the corresponding loop-closed-ssa-form phi-node at the loop-exit, and
replace the uses of its PHI_RESULT with the new def. However, the code that
does that expected to find only one such loop-exit phi-node per reduction
variable, which does not have to be the case, as in this example:

<bb 7>:
  # s_4 = PHI <s_3(3)>
  # s_10 = PHI <s_3(3)>
  D.1368_15 = *x_14(D);
  if (D.1368_15 < 0.0)
    goto <bb 8>;
  else
    goto <bb 9>;

<bb 8>:
  s_16 = -s_10;

<bb 9>:
  # s_1 = PHI <s_4(7), s_16(8)>
  return s_1;

s_3 has two loop-closed-ssa-form phi-nodes at the loop-exit, but the
vectorizer fixed the uses just for one of them (s_10) and not the other
(s_4).

We fix this by applying the necessary update to all relevant loop-exit
phis, and not only the first one that we encounter.

Bootstrapped with vectorization enabled on i386-linux. Bootstrapped on
powerpc64-linux. Tested on the vectorizer testcases on both platforms. Will
commit once full regression testing passes.

dorit

ChangeLog:

      * tree-vect-transform.c (vect_create_epilog_for_reduction): Update
      uses for all relevant loop-exit phis, not just the first.

Patch:

(See attached file: pr33299fix.txt)

Attachment: pr33299fix.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]