...which should have been after the early exit for non-vectorised
statements.  (Actually it could be after the !vec_stmt test in current
sources, but one of the later SVE patches needs it to be before, and
that's also the standard position in other vectorizable_* routines.)

Tested on x86_64-linux-gnu and applied as obvious.

It might be difficult to construct a reliable C or Fortran test for this,
since it only triggers if we miss a sinking opportunity.  A gimple FE
test might work though.  I'll try that when I have more time, but I
didn't want to hold the patch up until then.

Thanks,
Richard


2017-09-16  Richard Sandiford  <richard.sandif...@linaro.org>

gcc/
        PR tree-optimization/82228
        * tree-vect-loop.c (vectorizable_live_operation): Move initialization
        of ncopies.

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c        2017-09-15 13:03:19.144141117 +0100
+++ gcc/tree-vect-loop.c        2017-09-16 21:30:38.351984079 +0100
@@ -7029,11 +7029,6 @@ vectorizable_live_operation (gimple *stm
 
   gcc_assert (STMT_VINFO_LIVE_P (stmt_info));
 
-  if (slp_node)
-    ncopies = 1;
-  else
-    ncopies = vect_get_num_copies (loop_vinfo, vectype);
-
   if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
     return false;
 
@@ -7054,6 +7049,11 @@ vectorizable_live_operation (gimple *stm
       return true;
     }
 
+  if (slp_node)
+    ncopies = 1;
+  else
+    ncopies = vect_get_num_copies (loop_vinfo, vectype);
+
   if (!vec_stmt)
     /* No transformation required.  */
     return true;

Reply via email to