]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Remove new_phis from vect_create_epilog_for_reduction
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 13 Jul 2021 09:17:37 +0000 (10:17 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 13 Jul 2021 09:17:37 +0000 (10:17 +0100)
commit81ad6bfc078ca36a42446e2f2295102ffaac9ee1
treeae8e8304dd2065c4e90e6fe822762f6303e50bad
parentb68eb70bd6df8c4b846bddb4f0aeae9054b932bc
vect: Remove new_phis from vect_create_epilog_for_reduction

vect_create_epilog_for_reduction had a variable called new_phis.
It collected the statements that produce the exit block definitions
of the vector reduction accumulators.  Although those statements
are indeed phis initially, they are often replaced with normal
statements later, leading to puzzling code like:

          FOR_EACH_VEC_ELT (new_phis, i, new_phi)
            {
              int bit_offset;
              if (gimple_code (new_phi) == GIMPLE_PHI)
                vec_temp = PHI_RESULT (new_phi);
              else
                vec_temp = gimple_assign_lhs (new_phi);

Also, although the array collects statements, in practice all users want
the lhs instead.

This patch therefore replaces new_phis with a vector of gimple values
called “reduc_inputs”.

Also, reduction chains and ncopies>1 were handled with identical code
(and there was a comment saying so).  The patch unites them into
a single “if”.

gcc/
* tree-vect-loop.c (vect_create_epilog_for_reduction): Replace
the new_phis vector with a reduc_inputs vector.  Combine handling
of reduction chains and ncopies > 1.
gcc/tree-vect-loop.c