diff mbox series

[committed,vect] Be consistent in versioning threshold use

Message ID 57322ba1-fa42-1747-8491-983dcc58751d@arm.com
State New
Headers show
Series [committed,vect] Be consistent in versioning threshold use | expand

Commit Message

Andre Vieira (lists) Oct. 17, 2019, 12:36 p.m. UTC
Hi,

This piece of code was pre-approved by richi.

Retested by bootstrapping and regression testing on x86_64 (AVX512) and 
aarch64.

Committed in revision r277105.

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.
diff mbox series

Patch

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index b00d68b9de938148c24e088024b2e01bdceb2e81..72b80f46b1a9fa0bc8392809c286b5fac9a74451 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2155,6 +2155,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))
 	{
@@ -2175,6 +2176,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;
     }