vect: Respect slp decision when applying suggested uf [PR105940]
authorKewen Lin <linkw@linux.ibm.com>
Mon, 20 Jun 2022 12:44:21 +0000 (07:44 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Mon, 20 Jun 2022 12:44:21 +0000 (07:44 -0500)
commit86882d9feb6a534325d7162216696266898e36d0
tree791d7aad659e956a70043ffbe70d1b743caf09c8
parentc56f7983bedd6a36af6ba141cad92e1415682a70
vect: Respect slp decision when applying suggested uf [PR105940]

This follows Richi's suggestion in PR105940, it aims to avoid
inconsistent slp decision between when the suggested unroll
factor is worked out and when the suggested unroll factor is
applied.

If the previous slp decision is true when the suggested unroll
factor is worked out, when we are applying unroll factor we
don't need to start over with slp off if the analysis with slp
on fails.  On the other hand, if the previous slp decision is
false when the suggested unroll factor is worked out, when we
are applying unroll factor we can skip the slp handlings.

Function vect_is_simple_reduction saves reduction chains for
subsequent slp analyses, we have to disable this early otherwise
there is an ICE in vectorizable_reduction for below:

  if (REDUC_GROUP_FIRST_ELEMENT (stmt_info))
    gcc_assert (slp_node
&& REDUC_GROUP_FIRST_ELEMENT (stmt_info)
   == stmt_info);

PR tree-optimization/105940

gcc/ChangeLog:

* tree-vect-loop.cc (vect_analyze_loop_2): Add new parameter
slp_done_for_suggested_uf and adjust with it accordingly.
(vect_analyze_loop_1): Add new variable slp_done_for_suggested_uf,
pass it down to vect_analyze_loop_2 for the initial analysis and
applying suggested unroll factor.
(vect_is_simple_reduction): Add parameter slp and adjust with it.
(vect_analyze_scalar_cycles_1): Add parameter slp and pass down.
(vect_analyze_scalar_cycles): Likewise.
gcc/tree-vect-loop.cc