diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 87b3dc413b8bfdf0af30db18cfde4fcbfd2a5847..f52de2b6972dc0b8f63f812b64c60e9414962743 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -7362,8 +7362,6 @@ static vect_recog_func vect_vect_recog_func_ptrs[] = {
   /* These must come after the double widening ones.  */
 };
 
-const unsigned int NUM_PATTERNS = ARRAY_SIZE (vect_vect_recog_func_ptrs);
-
 /* Mark statements that are involved in a pattern.  */
 
 void
@@ -7518,7 +7516,7 @@ vect_mark_pattern_stmts (vec_info *vinfo,
 
 static void
 vect_pattern_recog_1 (vec_info *vinfo,
-		      vect_recog_func *recog_func, stmt_vec_info stmt_info)
+		      const vect_recog_func &recog_func, stmt_vec_info stmt_info)
 {
   gimple *pattern_stmt;
   tree pattern_vectype;
@@ -7538,7 +7536,7 @@ vect_pattern_recog_1 (vec_info *vinfo,
     }
 
   gcc_assert (!STMT_VINFO_PATTERN_DEF_SEQ (stmt_info));
-  pattern_stmt = recog_func->fn (vinfo, stmt_info, &pattern_vectype);
+  pattern_stmt = recog_func.fn (vinfo, stmt_info, &pattern_vectype);
   if (!pattern_stmt)
     {
       /* Clear any half-formed pattern definition sequence.  */
@@ -7550,7 +7548,7 @@ vect_pattern_recog_1 (vec_info *vinfo,
   if (dump_enabled_p ())
     dump_printf_loc (MSG_NOTE, vect_location,
 		     "%s pattern recognized: %G",
-		     recog_func->name, pattern_stmt);
+		     recog_func.name, pattern_stmt);
 
   /* Mark the stmts that are involved in the pattern. */
   vect_mark_pattern_stmts (vinfo, stmt_info, pattern_stmt, pattern_vectype);
@@ -7658,8 +7656,8 @@ vect_pattern_recog (vec_info *vinfo)
 	    continue;
 
 	  /* Scan over all generic vect_recog_xxx_pattern functions.  */
-	  for (unsigned j = 0; j < NUM_PATTERNS; j++)
-	    vect_pattern_recog_1 (vinfo, &vect_vect_recog_func_ptrs[j],
+	  for (const auto &func_ptr : vect_vect_recog_func_ptrs)
+	    vect_pattern_recog_1 (vinfo, func_ptr,
 				  stmt_info);
 	}
     }