Commit 49d8df1b by Richard Sandiford Committed by Richard Sandiford

[7/n] PR85694: Add a vect_pattern_detected helper

This message is a long write-up for a patch that simply adds a common
routine for printing the "vector_foo_pattern: detected:" messages.

The reason for doing this is that some routines check for target support
themselves and some leave it to vect_pattern_recog_1.  Those that leave
it to vect_pattern_recog_1 currently print these "detected:" messages if
the statements have the right form, even if the pattern is eventually
discarded.  IMO that's useful, and a lot of existing scan tests rely on it.

However, a later patch makes patterns do their own testing, and stops
them creating pattern statements until the tests have passed.  This means
(a) they need to print the "detected:" message earlier and (b) the pattern
statement won't be around to print.

The patch therefore makes all routines print the original statement
rather than the pattern one.  That information isn't obvious otherwise,
whereas vect_pattern_recog_1 already prints the pattern statement
in the case of a successful match.  This also avoids the previous
situation in which a routine could print "detected:" and then
silently bail out before saying what had been detected.

2018-06-20  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vect-patterns.c (vect_pattern_detected): New function.
	(vect_recog_dot_prod_patternm, vect_recog_sad_pattern)
	(vect_recog_widen_mult_pattern, vect_recog_widen_sum_pattern)
	(vect_recog_over_widening_pattern, vect_recog_widen_shift_pattern
	(vect_recog_rotate_pattern, vect_recog_vector_vector_shift_pattern)
	(vect_recog_mult_pattern, vect_recog_divmod_pattern)
	(vect_recog_mixed_size_cond_pattern, vect_recog_bool_pattern)
	(vect_recog_mask_conversion_pattern)
	(vect_try_gather_scatter_pattern): Likewise.

From-SVN: r261790
parent 25927307
2018-06-20 Richard Sandiford <richard.sandiford@arm.com> 2018-06-20 Richard Sandiford <richard.sandiford@arm.com>
* tree-vect-patterns.c (vect_pattern_detected): New function.
(vect_recog_dot_prod_patternm, vect_recog_sad_pattern)
(vect_recog_widen_mult_pattern, vect_recog_widen_sum_pattern)
(vect_recog_over_widening_pattern, vect_recog_widen_shift_pattern
(vect_recog_rotate_pattern, vect_recog_vector_vector_shift_pattern)
(vect_recog_mult_pattern, vect_recog_divmod_pattern)
(vect_recog_mixed_size_cond_pattern, vect_recog_bool_pattern)
(vect_recog_mask_conversion_pattern)
(vect_try_gather_scatter_pattern): Likewise.
2018-06-20 Richard Sandiford <richard.sandiford@arm.com>
* tree-vect-patterns.c (vect_get_internal_def): New function. * tree-vect-patterns.c (vect_get_internal_def): New function.
(vect_recog_dot_prod_pattern, vect_recog_sad_pattern) (vect_recog_dot_prod_pattern, vect_recog_sad_pattern)
(vect_recog_vector_vector_shift_pattern, check_bool_pattern) (vect_recog_vector_vector_shift_pattern, check_bool_pattern)
......
...@@ -107,6 +107,19 @@ static vect_recog_func vect_vect_recog_func_ptrs[NUM_PATTERNS] = { ...@@ -107,6 +107,19 @@ static vect_recog_func vect_vect_recog_func_ptrs[NUM_PATTERNS] = {
{ vect_recog_mask_conversion_pattern, "mask_conversion" } { vect_recog_mask_conversion_pattern, "mask_conversion" }
}; };
/* Report that we've found an instance of pattern PATTERN in
statement STMT. */
static void
vect_pattern_detected (const char *name, gimple *stmt)
{
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location, "%s: detected: ", name);
dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
}
}
static inline void static inline void
append_pattern_def_seq (stmt_vec_info stmt_info, gimple *stmt) append_pattern_def_seq (stmt_vec_info stmt_info, gimple *stmt)
{ {
...@@ -432,22 +445,16 @@ vect_recog_dot_prod_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -432,22 +445,16 @@ vect_recog_dot_prod_pattern (vec<gimple *> *stmts, tree *type_in,
return NULL; return NULL;
} }
vect_pattern_detected ("vect_recog_dot_prod_pattern", last_stmt);
half_type = TREE_TYPE (oprnd00); half_type = TREE_TYPE (oprnd00);
*type_in = half_type; *type_in = half_type;
*type_out = type; *type_out = type;
/* Pattern detected. Create a stmt to be used to replace the pattern: */
var = vect_recog_temp_ssa_var (type, NULL); var = vect_recog_temp_ssa_var (type, NULL);
pattern_stmt = gimple_build_assign (var, DOT_PROD_EXPR, pattern_stmt = gimple_build_assign (var, DOT_PROD_EXPR,
oprnd00, oprnd01, oprnd1); oprnd00, oprnd01, oprnd1);
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_dot_prod_pattern: detected: ");
dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
}
return pattern_stmt; return pattern_stmt;
} }
...@@ -632,21 +639,15 @@ vect_recog_sad_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -632,21 +639,15 @@ vect_recog_sad_pattern (vec<gimple *> *stmts, tree *type_in,
|| TYPE_PRECISION (sum_type) < TYPE_PRECISION (half_type0) * 2) || TYPE_PRECISION (sum_type) < TYPE_PRECISION (half_type0) * 2)
return NULL; return NULL;
vect_pattern_detected ("vect_recog_sad_pattern", last_stmt);
*type_in = TREE_TYPE (sad_oprnd0); *type_in = TREE_TYPE (sad_oprnd0);
*type_out = sum_type; *type_out = sum_type;
/* Pattern detected. Create a stmt to be used to replace the pattern: */
tree var = vect_recog_temp_ssa_var (sum_type, NULL); tree var = vect_recog_temp_ssa_var (sum_type, NULL);
gimple *pattern_stmt = gimple_build_assign (var, SAD_EXPR, sad_oprnd0, gimple *pattern_stmt = gimple_build_assign (var, SAD_EXPR, sad_oprnd0,
sad_oprnd1, plus_oprnd1); sad_oprnd1, plus_oprnd1);
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_sad_pattern: detected: ");
dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
}
return pattern_stmt; return pattern_stmt;
} }
...@@ -919,9 +920,7 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts, ...@@ -919,9 +920,7 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts,
TYPE_UNSIGNED (type)); TYPE_UNSIGNED (type));
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_widen_mult_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_widen_mult_pattern: detected:\n");
/* Check target support */ /* Check target support */
vectype = get_vectype_for_scalar_type (half_type0); vectype = get_vectype_for_scalar_type (half_type0);
...@@ -970,9 +969,6 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts, ...@@ -970,9 +969,6 @@ vect_recog_widen_mult_pattern (vec<gimple *> *stmts,
gimple_assign_lhs (pattern_stmt)); gimple_assign_lhs (pattern_stmt));
} }
if (dump_enabled_p ())
dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
return pattern_stmt; return pattern_stmt;
} }
...@@ -1230,20 +1226,15 @@ vect_recog_widen_sum_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -1230,20 +1226,15 @@ vect_recog_widen_sum_pattern (vec<gimple *> *stmts, tree *type_in,
return NULL; return NULL;
oprnd0 = gimple_assign_rhs1 (stmt); oprnd0 = gimple_assign_rhs1 (stmt);
vect_pattern_detected ("vect_recog_widen_sum_pattern", last_stmt);
*type_in = half_type; *type_in = half_type;
*type_out = type; *type_out = type;
/* Pattern detected. Create a stmt to be used to replace the pattern: */
var = vect_recog_temp_ssa_var (type, NULL); var = vect_recog_temp_ssa_var (type, NULL);
pattern_stmt = gimple_build_assign (var, WIDEN_SUM_EXPR, oprnd0, oprnd1); pattern_stmt = gimple_build_assign (var, WIDEN_SUM_EXPR, oprnd0, oprnd1);
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_widen_sum_pattern: detected: ");
dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
}
return pattern_stmt; return pattern_stmt;
} }
...@@ -1603,12 +1594,7 @@ vect_recog_over_widening_pattern (vec<gimple *> *stmts, ...@@ -1603,12 +1594,7 @@ vect_recog_over_widening_pattern (vec<gimple *> *stmts,
return NULL; return NULL;
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_over_widening_pattern", stmts->last ());
{
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_over_widening_pattern: detected: ");
dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
}
return pattern_stmt; return pattern_stmt;
} }
...@@ -1740,9 +1726,7 @@ vect_recog_widen_shift_pattern (vec<gimple *> *stmts, ...@@ -1740,9 +1726,7 @@ vect_recog_widen_shift_pattern (vec<gimple *> *stmts,
return NULL; return NULL;
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_widen_shift_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_widen_shift_pattern: detected:\n");
/* Check target support. */ /* Check target support. */
vectype = get_vectype_for_scalar_type (half_type0); vectype = get_vectype_for_scalar_type (half_type0);
...@@ -1773,9 +1757,6 @@ vect_recog_widen_shift_pattern (vec<gimple *> *stmts, ...@@ -1773,9 +1757,6 @@ vect_recog_widen_shift_pattern (vec<gimple *> *stmts,
STMT_VINFO_VECTYPE (new_stmt_info) = vectype; STMT_VINFO_VECTYPE (new_stmt_info) = vectype;
} }
if (dump_enabled_p ())
dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
return pattern_stmt; return pattern_stmt;
} }
...@@ -2010,17 +1991,12 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out) ...@@ -2010,17 +1991,12 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out)
append_pattern_def_seq (stmt_vinfo, def_stmt); append_pattern_def_seq (stmt_vinfo, def_stmt);
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_rotate_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_rotate_pattern: detected:\n");
/* Pattern supported. Create a stmt to be used to replace the pattern. */ /* Pattern supported. Create a stmt to be used to replace the pattern. */
var = vect_recog_temp_ssa_var (type, NULL); var = vect_recog_temp_ssa_var (type, NULL);
pattern_stmt = gimple_build_assign (var, BIT_IOR_EXPR, var1, var2); pattern_stmt = gimple_build_assign (var, BIT_IOR_EXPR, var1, var2);
if (dump_enabled_p ())
dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
return pattern_stmt; return pattern_stmt;
} }
...@@ -2153,17 +2129,12 @@ vect_recog_vector_vector_shift_pattern (vec<gimple *> *stmts, ...@@ -2153,17 +2129,12 @@ vect_recog_vector_vector_shift_pattern (vec<gimple *> *stmts,
} }
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_vector_vector_shift_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_vector_vector_shift_pattern: detected:\n");
/* Pattern supported. Create a stmt to be used to replace the pattern. */ /* Pattern supported. Create a stmt to be used to replace the pattern. */
var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL); var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL);
pattern_stmt = gimple_build_assign (var, rhs_code, oprnd0, def); pattern_stmt = gimple_build_assign (var, rhs_code, oprnd0, def);
if (dump_enabled_p ())
dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
return pattern_stmt; return pattern_stmt;
} }
...@@ -2530,13 +2501,7 @@ vect_recog_mult_pattern (vec<gimple *> *stmts, ...@@ -2530,13 +2501,7 @@ vect_recog_mult_pattern (vec<gimple *> *stmts,
return NULL; return NULL;
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_mult_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_mult_pattern: detected:\n");
if (dump_enabled_p ())
dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM,
pattern_stmt,0);
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
*type_in = vectype; *type_in = vectype;
...@@ -2652,9 +2617,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts, ...@@ -2652,9 +2617,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
return NULL; return NULL;
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_divmod_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_divmod_pattern: detected:\n");
cond = build2 (LT_EXPR, boolean_type_node, oprnd0, cond = build2 (LT_EXPR, boolean_type_node, oprnd0,
build_int_cst (itype, 0)); build_int_cst (itype, 0));
...@@ -2738,10 +2701,6 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts, ...@@ -2738,10 +2701,6 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
signmask); signmask);
} }
if (dump_enabled_p ())
dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt,
0);
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
*type_in = vectype; *type_in = vectype;
...@@ -2992,12 +2951,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts, ...@@ -2992,12 +2951,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
} }
/* Pattern detected. */ /* Pattern detected. */
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_divmod_pattern", last_stmt);
{
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_divmod_pattern: detected: ");
dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_stmt, 0);
}
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
...@@ -3157,9 +3111,7 @@ vect_recog_mixed_size_cond_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -3157,9 +3111,7 @@ vect_recog_mixed_size_cond_pattern (vec<gimple *> *stmts, tree *type_in,
*type_in = vecitype; *type_in = vecitype;
*type_out = vectype; *type_out = vectype;
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_mixed_size_cond_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_mixed_size_cond_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
...@@ -3729,9 +3681,7 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -3729,9 +3681,7 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
*type_out = vectype; *type_out = vectype;
*type_in = vectype; *type_in = vectype;
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_bool_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_bool_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
...@@ -3770,9 +3720,7 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -3770,9 +3720,7 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
*type_out = vectype; *type_out = vectype;
*type_in = vectype; *type_in = vectype;
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_bool_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_bool_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
...@@ -3829,9 +3777,8 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -3829,9 +3777,8 @@ vect_recog_bool_pattern (vec<gimple *> *stmts, tree *type_in,
*type_out = vectype; *type_out = vectype;
*type_in = vectype; *type_in = vectype;
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_bool_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_bool_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
else else
...@@ -3966,9 +3913,7 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -3966,9 +3913,7 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
*type_out = vectype1; *type_out = vectype1;
*type_in = vectype1; *type_in = vectype1;
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_mask_conversion_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_mask_conversion_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
...@@ -4092,9 +4037,7 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -4092,9 +4037,7 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
*type_out = vectype1; *type_out = vectype1;
*type_in = vectype1; *type_in = vectype1;
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_mask_conversion_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_mask_conversion_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
...@@ -4140,9 +4083,7 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -4140,9 +4083,7 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
*type_out = vectype1; *type_out = vectype1;
*type_in = vectype1; *type_in = vectype1;
stmts->safe_push (last_stmt); stmts->safe_push (last_stmt);
if (dump_enabled_p ()) vect_pattern_detected ("vect_recog_mask_conversion_pattern", last_stmt);
dump_printf_loc (MSG_NOTE, vect_location,
"vect_recog_mask_conversion_pattern: detected:\n");
return pattern_stmt; return pattern_stmt;
} }
...@@ -4324,10 +4265,7 @@ vect_try_gather_scatter_pattern (gimple *stmt, stmt_vec_info last_stmt_info, ...@@ -4324,10 +4265,7 @@ vect_try_gather_scatter_pattern (gimple *stmt, stmt_vec_info last_stmt_info,
tree vectype = STMT_VINFO_VECTYPE (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info);
*type_out = vectype; *type_out = vectype;
*type_in = vectype; *type_in = vectype;
vect_pattern_detected ("gather/scatter pattern", stmt);
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
"gather/scatter pattern detected:\n");
return pattern_stmt; return pattern_stmt;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment