[vect] Be consistent in versioning threshold use
authorAndre Vieira <andre.simoesdiasvieira@arm.com>
Thu, 17 Oct 2019 12:35:33 +0000 (12:35 +0000)
committerAndre Vieira <avieira@gcc.gnu.org>
Thu, 17 Oct 2019 12:35:33 +0000 (12:35 +0000)
gcc/ChangeLog:
2019-10-17  Andre Vieira  <andre.simoesdiasvieira@arm.com>

* tree-vect-loop.c (vect_analyze_loop_2): Use same condition to decide
when to use versioning threshold.

From-SVN: r277105

gcc/ChangeLog
gcc/tree-vect-loop.c

index 9b17a6d5bbd7b4fb8ded5cebb038da6079cf5c2c..9c0e754360e1b890f09e36477e3ded745f8f2269 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-17  Andre Vieira  <andre.simoesdiasvieira@arm.com>
+
+       * tree-vect-loop.c (vect_analyze_loop_2): Use same condition to decide
+       when to use versioning threshold.
+
 2019-10-17  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * tree-vect-loop.c (determine_peel_for_niter): New function contained
index df9f159e7744426c1f6bbe91b0aabe1b921bcdeb..fa5c2162f2f81bf6f6ac31b9abef6bb60b422185 100644 (file)
@@ -2154,6 +2154,7 @@ start_over:
   if (LOOP_REQUIRES_VERSIONING (loop_vinfo))
     {
       poly_uint64 niters_th = 0;
+      unsigned int th = LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo);
 
       if (!vect_use_loop_mask_for_alignment_p (loop_vinfo))
        {
@@ -2174,6 +2175,14 @@ start_over:
       /* One additional iteration because of peeling for gap.  */
       if (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
        niters_th += 1;
+
+      /*  Use the same condition as vect_transform_loop to decide when to use
+         the cost to determine a versioning threshold.  */
+      if (th >= vect_vf_for_cost (loop_vinfo)
+         && !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+         && ordered_p (th, niters_th))
+       niters_th = ordered_max (poly_uint64 (th), niters_th);
+
       LOOP_VINFO_VERSIONING_THRESHOLD (loop_vinfo) = niters_th;
     }