aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.cc
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2024-01-12 15:26:29 +0000
committerTamar Christina <tamar.christina@arm.com>2024-01-12 15:31:48 +0000
commite79c5855ab39d96baa7c6bec63eb97715abcf68d (patch)
tree7c291f505d5ece701a8ba7a64129d11feb4f69f6 /gcc/tree-vect-loop.cc
parent99c0a540d6689ede068f9ba98af6f38c3cd71362 (diff)
downloadgcc-e79c5855ab39d96baa7c6bec63eb97715abcf68d.zip
gcc-e79c5855ab39d96baa7c6bec63eb97715abcf68d.tar.gz
gcc-e79c5855ab39d96baa7c6bec63eb97715abcf68d.tar.bz2
middle-end: fill in reduction PHI for all alt exits [PR113178]
When we have a loop with more than 2 exits and a reduction I forgot to fill in the PHI value for all alternate exits. All alternate exits use the same PHI value so we should loop over the new PHI elements and copy the value across since we call the reduction calculation code only once for all exits. This was normally covered up by earlier parts of the compiler rejecting loops incorrectly (which has been fixed now). Note that while I can use the loop in all cases, the reason I separated out the main and alt exit is so that if you pass the wrong edge the macro will assert. gcc/ChangeLog: PR tree-optimization/113178 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Fill in all alternate exits. gcc/testsuite/ChangeLog: PR tree-optimization/113178 * gcc.dg/vect/vect-early-break_101-pr113178.c: New test. * gcc.dg/vect/vect-early-break_102-pr113178.c: New test.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r--gcc/tree-vect-loop.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 0f4a557..44022bf 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6247,7 +6247,13 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
phi = create_phi_node (new_def, exit_bb);
if (j)
def = gimple_get_lhs (vec_stmts[j]);
- SET_PHI_ARG_DEF (phi, loop_exit->dest_idx, def);
+ if (LOOP_VINFO_IV_EXIT (loop_vinfo) == loop_exit)
+ SET_PHI_ARG_DEF (phi, loop_exit->dest_idx, def);
+ else
+ {
+ for (unsigned k = 0; k < gimple_phi_num_args (phi); k++)
+ SET_PHI_ARG_DEF (phi, k, def);
+ }
new_def = gimple_convert (&stmts, vectype, new_def);
reduc_inputs.quick_push (new_def);
}