public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR68776
@ 2015-12-18 13:50 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2015-12-18 13:50 UTC (permalink / raw)
  To: gcc-patches


The following should fix PR68776, a testism with the new mult pattern.
The patch changes pattern recog to print a more specific 'pattern 
recognized' and make the two offending testcases scan for what it is 
looking.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2015-12-18  Richard Biener  <rguenther@suse.de>

	PR testsuite/68776
	* tree-vect-patterns.c (struct vect_recog_func): New.
	(vect_vect_recog_func_ptrs): Make an array of function name pairs.
	(vect_pattern_recog_1): Print the recognized pattern name.  Return
	true if a pattern was recognized.
	(vect_pattern_recog): Adjust.  Stop iterating over pattern recognition
	functions on a stmt if a pattern was recognized.

	* gcc.dg/vect/vect-widen-mult-const-s16.c: Adjust.
	* gcc.dg/vect/vect-widen-mult-const-u16.c: Likewise.

Index: gcc/tree-vect-patterns.c
===================================================================
--- gcc/tree-vect-patterns.c	(revision 231805)
+++ gcc/tree-vect-patterns.c	(working copy)
@@ -69,21 +69,28 @@ static gimple *vect_recog_mixed_size_con
 						  tree *, tree *);
 static gimple *vect_recog_bool_pattern (vec<gimple *> *, tree *, tree *);
 static gimple *vect_recog_mask_conversion_pattern (vec<gimple *> *, tree *, tree *);
-static vect_recog_func_ptr vect_vect_recog_func_ptrs[NUM_PATTERNS] = {
-	vect_recog_widen_mult_pattern,
-	vect_recog_widen_sum_pattern,
-	vect_recog_dot_prod_pattern,
-        vect_recog_sad_pattern,
-	vect_recog_pow_pattern,
-	vect_recog_widen_shift_pattern,
-	vect_recog_over_widening_pattern,
-	vect_recog_rotate_pattern,
-	vect_recog_vector_vector_shift_pattern,
-	vect_recog_divmod_pattern,
-	vect_recog_mult_pattern,
-	vect_recog_mixed_size_cond_pattern,
-	vect_recog_bool_pattern,
-	vect_recog_mask_conversion_pattern};
+
+struct vect_recog_func
+{
+  vect_recog_func_ptr fn;
+  const char *name;
+};
+static vect_recog_func vect_vect_recog_func_ptrs[NUM_PATTERNS] = {
+      { vect_recog_widen_mult_pattern, "widen_mult" },
+      { vect_recog_widen_sum_pattern, "widen_sum" },
+      { vect_recog_dot_prod_pattern, "dot_prod" },
+      { vect_recog_sad_pattern, "sad" },
+      { vect_recog_pow_pattern, "pow" },
+      { vect_recog_widen_shift_pattern, "widen_shift" },
+      { vect_recog_over_widening_pattern, "over_widening" },
+      { vect_recog_rotate_pattern, "rotate" },
+      { vect_recog_vector_vector_shift_pattern, "vector_vector_shift" },
+      {	vect_recog_divmod_pattern, "divmod" },
+      {	vect_recog_mult_pattern, "mult" },
+      {	vect_recog_mixed_size_cond_pattern, "mixed_size_cond" },
+      {	vect_recog_bool_pattern, "bool" },
+      {	vect_recog_mask_conversion_pattern, "mask_conversion" }
+};
 
 static inline void
 append_pattern_def_seq (stmt_vec_info stmt_info, gimple *stmt)
@@ -3791,8 +3798,8 @@ vect_mark_pattern_stmts (gimple *orig_st
    This function also does some bookkeeping, as explained in the documentation
    for vect_recog_pattern.  */
 
-static void
-vect_pattern_recog_1 (vect_recog_func_ptr vect_recog_func,
+static bool
+vect_pattern_recog_1 (vect_recog_func *recog_func,
 		      gimple_stmt_iterator si,
 		      vec<gimple *> *stmts_to_replace)
 {
@@ -3807,9 +3814,9 @@ vect_pattern_recog_1 (vect_recog_func_pt
 
   stmts_to_replace->truncate (0);
   stmts_to_replace->quick_push (stmt);
-  pattern_stmt = (* vect_recog_func) (stmts_to_replace, &type_in, &type_out);
+  pattern_stmt = recog_func->fn (stmts_to_replace, &type_in, &type_out);
   if (!pattern_stmt)
-    return;
+    return false;
 
   stmt = stmts_to_replace->last ();
   stmt_info = vinfo_for_stmt (stmt);
@@ -3831,13 +3838,13 @@ vect_pattern_recog_1 (vect_recog_func_pt
       /* Check target support  */
       type_in = get_vectype_for_scalar_type (type_in);
       if (!type_in)
-	return;
+	return false;
       if (type_out)
 	type_out = get_vectype_for_scalar_type (type_out);
       else
 	type_out = type_in;
       if (!type_out)
-	return;
+	return false;
       pattern_vectype = type_out;
 
       if (is_gimple_assign (pattern_stmt))
@@ -3853,14 +3860,14 @@ vect_pattern_recog_1 (vect_recog_func_pt
       if (!optab
           || (icode = optab_handler (optab, vec_mode)) == CODE_FOR_nothing
           || (insn_data[icode].operand[0].mode != TYPE_MODE (type_out)))
-	return;
+	return false;
     }
 
   /* Found a vectorizable pattern.  */
   if (dump_enabled_p ())
     {
       dump_printf_loc (MSG_NOTE, vect_location,
-                       "pattern recognized: ");
+                       "%s pattern recognized: ", recog_func->name);
       dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
     }
 
@@ -3892,6 +3899,8 @@ vect_pattern_recog_1 (vect_recog_func_pt
 
       vect_mark_pattern_stmts (stmt, pattern_stmt, NULL_TREE);
     }
+
+  return true;
 }
 
 
@@ -3980,7 +3989,6 @@ vect_pattern_recog (vec_info *vinfo)
   unsigned int nbbs;
   gimple_stmt_iterator si;
   unsigned int i, j;
-  vect_recog_func_ptr vect_recog_func;
   auto_vec<gimple *, 1> stmts_to_replace;
   gimple *stmt;
 
@@ -4003,11 +4011,9 @@ vect_pattern_recog (vec_info *vinfo)
 	    {
 	      /* Scan over all generic vect_recog_xxx_pattern functions.  */
 	      for (j = 0; j < NUM_PATTERNS; j++)
-		{
-		  vect_recog_func = vect_vect_recog_func_ptrs[j];
-		  vect_pattern_recog_1 (vect_recog_func, si,
-					&stmts_to_replace);
-		}
+		if (vect_pattern_recog_1 (&vect_vect_recog_func_ptrs[j], si,
+					  &stmts_to_replace))
+		  break;
 	    }
 	}
     }
@@ -4024,11 +4030,9 @@ vect_pattern_recog (vec_info *vinfo)
 
 	  /* Scan over all generic vect_recog_xxx_pattern functions.  */
 	  for (j = 0; j < NUM_PATTERNS; j++)
-	    {
-	      vect_recog_func = vect_vect_recog_func_ptrs[j];
-	      vect_pattern_recog_1 (vect_recog_func, si,
-				    &stmts_to_replace);
-	    }
+	    if (vect_pattern_recog_1 (&vect_vect_recog_func_ptrs[j], si,
+				      &stmts_to_replace))
+	      break;
 	}
     }
 }
Index: gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c	(revision 231805)
+++ gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c	(working copy)
@@ -56,5 +56,5 @@ int main (void)
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_widen_mult_hi_to_si } } } */
 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
-/* { dg-final { scan-tree-dump-times "pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
+/* { dg-final { scan-tree-dump-times "widen_mult pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
 
Index: gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c	(revision 231805)
+++ gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c	(working copy)
@@ -73,4 +73,4 @@ int main (void)
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" { target vect_widen_mult_hi_to_si } } } */
 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
-/* { dg-final { scan-tree-dump-times "pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */
+/* { dg-final { scan-tree-dump-times "widen_mult pattern recognized" 2 "vect" { target vect_widen_mult_hi_to_si_pattern } } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-18 13:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 13:50 [PATCH] Fix PR68776 Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).