For counted loops, `vect_set_loop_condition' replaces the scalar
main exit condition with a condition based on the vectorized
iteration count.

For uncounted loops using partial vectors, however, the main
exit is handled as an early-break exit, and its condition has
already been transformed by the early-break machinery.

Avoid replacing this condition a second time, since doing so
would discard the vectorized early-break exit test.

gcc/ChangeLog:

        * tree-vect-loop-manip.cc (vect_set_loop_condition): Preserve
        the existing exit condition for uncounted loops using partial
        vectors.
---
 gcc/tree-vect-loop-manip.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 07a75400174..f57118337ca 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -1452,6 +1452,13 @@ vect_set_loop_condition (class loop *loop, edge loop_e, 
loop_vec_info loop_vinfo
                                                step, final_iv,
                                                niters_maybe_zero);
 
+  if (loop_vinfo
+      && (LOOP_VINFO_NITERS_UNCOUNTED_P (loop_vinfo)
+         && LOOP_VINFO_USING_PARTIAL_VECTORS_P (loop_vinfo)))
+    return;
+
+  gcc_assert (cond_stmt);
+
   /* A peeled early-break loop is entered only when it has at least one
      vector iteration to execute.  Test the IV after that iteration rather
      than before it, regardless of the style of loop control.  */
-- 
2.43.0

Reply via email to