If the user has requested loop unrolling through pragma GCC unroll then at the
moment we only set LOOP_VINFO_USER_UNROLL if the vectorizer has not overrode the
unroll factor (through backend costing) or if the VF made the requested unroll
factor be 1.

But of these events are costing related, and so it stands to reason that we
should set LOOP_VINFO_USER_UNROLL to we return the RTL unroller to use the
backend costing for any further unrolling.

Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues.

Ok for master? Tests using this are in the next patch.

Thanks,
Tamar

gcc/ChangeLog:

        * tree-vect-loop.cc (vect_analyze_loop_1): If the unroll pragma was set
        mark it as handled.

---
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 
3b56f865ec7c3fdb8e9def37ec446a25086b4e28..f393b45232b3390959a2be756db3aa8b35002bf0
 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -2941,11 +2941,13 @@ vect_analyze_loop_1 (class loop *loop, vec_info_shared 
*shared,
              {
                delete loop_vinfo;
                loop_vinfo = unroll_vinfo;
-               LOOP_VINFO_USER_UNROLL (loop_vinfo) = user_unroll > 1;
              }
            else
              delete unroll_vinfo;
          }
+
+       /* Record that we have honored a user unroll factor.  */
+       LOOP_VINFO_USER_UNROLL (loop_vinfo) = user_unroll > 1;
     }
 
   /* Remember the autodetected vector mode.  */


-- 
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3b56f865ec7c3fdb8e9def37ec446a25086b4e28..f393b45232b3390959a2be756db3aa8b35002bf0 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -2941,11 +2941,13 @@ vect_analyze_loop_1 (class loop *loop, vec_info_shared *shared,
 	      {
 		delete loop_vinfo;
 		loop_vinfo = unroll_vinfo;
-		LOOP_VINFO_USER_UNROLL (loop_vinfo) = user_unroll > 1;
 	      }
 	    else
 	      delete unroll_vinfo;
 	  }
+
+	/* Record that we have honored a user unroll factor.  */
+	LOOP_VINFO_USER_UNROLL (loop_vinfo) = user_unroll > 1;
     }
 
   /* Remember the autodetected vector mode.  */

Reply via email to