Add a vect_worthwhile_without_simd_p helper routine
The vectoriser sometimes considers lowering "vector" operations into N scalar word operations. This N needs to be fixed at compile time, so the condition guarding it needs to change when variable-lengh vectors are added. This patch puts the condition into a helper routine so that there's only one place to update. 2017-09-14 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree-vectorizer.h (vect_min_worthwhile_factor): Delete. (vect_worthwhile_without_simd_p): Declare. * tree-vect-loop.c (vect_worthwhile_without_simd_p): New function. (vectorizable_reduction): Use it. * tree-vect-stmts.c (vectorizable_shift): Likewise. (vectorizable_operation): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r252765
This commit is contained in:
parent
e8f142e282
commit
ca09abcb39
4 changed files with 33 additions and 24 deletions
|
@ -1,3 +1,14 @@
|
|||
2017-09-14 Richard Sandiford <richard.sandiford@linaro.org>
|
||||
Alan Hayward <alan.hayward@arm.com>
|
||||
David Sherwood <david.sherwood@arm.com>
|
||||
|
||||
* tree-vectorizer.h (vect_min_worthwhile_factor): Delete.
|
||||
(vect_worthwhile_without_simd_p): Declare.
|
||||
* tree-vect-loop.c (vect_worthwhile_without_simd_p): New function.
|
||||
(vectorizable_reduction): Use it.
|
||||
* tree-vect-stmts.c (vectorizable_shift): Likewise.
|
||||
(vectorizable_operation): Likewise.
|
||||
|
||||
2017-09-14 Richard Sandiford <richard.sandiford@linaro.org>
|
||||
Alan Hayward <alan.hayward@arm.com>
|
||||
David Sherwood <david.sherwood@arm.com>
|
||||
|
|
|
@ -6030,8 +6030,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
dump_printf (MSG_NOTE, "op not supported by target.\n");
|
||||
|
||||
if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
|
||||
|| LOOP_VINFO_VECT_FACTOR (loop_vinfo)
|
||||
< vect_min_worthwhile_factor (code))
|
||||
|| !vect_worthwhile_without_simd_p (loop_vinfo, code))
|
||||
return false;
|
||||
|
||||
if (dump_enabled_p ())
|
||||
|
@ -6040,8 +6039,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
|
||||
/* Worthwhile without SIMD support? */
|
||||
if (!VECTOR_MODE_P (TYPE_MODE (vectype_in))
|
||||
&& LOOP_VINFO_VECT_FACTOR (loop_vinfo)
|
||||
< vect_min_worthwhile_factor (code))
|
||||
&& !vect_worthwhile_without_simd_p (loop_vinfo, code))
|
||||
{
|
||||
if (dump_enabled_p ())
|
||||
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
|
||||
|
@ -6492,6 +6490,18 @@ vect_min_worthwhile_factor (enum tree_code code)
|
|||
}
|
||||
}
|
||||
|
||||
/* Return true if VINFO indicates we are doing loop vectorization and if
|
||||
it is worth decomposing CODE operations into scalar operations for
|
||||
that loop's vectorization factor. */
|
||||
|
||||
bool
|
||||
vect_worthwhile_without_simd_p (vec_info *vinfo, tree_code code)
|
||||
{
|
||||
loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (vinfo);
|
||||
return (loop_vinfo
|
||||
&& (LOOP_VINFO_VECT_FACTOR (loop_vinfo)
|
||||
>= vect_min_worthwhile_factor (code)));
|
||||
}
|
||||
|
||||
/* Function vectorizable_induction
|
||||
|
||||
|
|
|
@ -4869,7 +4869,6 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
bool scalar_shift_arg = true;
|
||||
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
|
||||
vec_info *vinfo = stmt_info->vinfo;
|
||||
int vf;
|
||||
|
||||
if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo)
|
||||
return false;
|
||||
|
@ -4937,11 +4936,6 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (loop_vinfo)
|
||||
vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
|
||||
else
|
||||
vf = 1;
|
||||
|
||||
/* Multiple types in SLP are handled by creating the appropriate number of
|
||||
vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in
|
||||
case of SLP. */
|
||||
|
@ -5086,8 +5080,8 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
"op not supported by target.\n");
|
||||
/* Check only during analysis. */
|
||||
if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
|
||||
|| (vf < vect_min_worthwhile_factor (code)
|
||||
&& !vec_stmt))
|
||||
|| (!vec_stmt
|
||||
&& !vect_worthwhile_without_simd_p (vinfo, code)))
|
||||
return false;
|
||||
if (dump_enabled_p ())
|
||||
dump_printf_loc (MSG_NOTE, vect_location,
|
||||
|
@ -5095,9 +5089,9 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
}
|
||||
|
||||
/* Worthwhile without SIMD support? Check only during analysis. */
|
||||
if (!VECTOR_MODE_P (TYPE_MODE (vectype))
|
||||
&& vf < vect_min_worthwhile_factor (code)
|
||||
&& !vec_stmt)
|
||||
if (!vec_stmt
|
||||
&& !VECTOR_MODE_P (TYPE_MODE (vectype))
|
||||
&& !vect_worthwhile_without_simd_p (vinfo, code))
|
||||
{
|
||||
if (dump_enabled_p ())
|
||||
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
|
||||
|
@ -5241,7 +5235,6 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
tree vop0, vop1, vop2;
|
||||
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
|
||||
vec_info *vinfo = stmt_info->vinfo;
|
||||
int vf;
|
||||
|
||||
if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo)
|
||||
return false;
|
||||
|
@ -5368,11 +5361,6 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
}
|
||||
}
|
||||
|
||||
if (loop_vinfo)
|
||||
vf = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
|
||||
else
|
||||
vf = 1;
|
||||
|
||||
/* Multiple types in SLP are handled by creating the appropriate number of
|
||||
vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in
|
||||
case of SLP. */
|
||||
|
@ -5414,7 +5402,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
"op not supported by target.\n");
|
||||
/* Check only during analysis. */
|
||||
if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
|
||||
|| (!vec_stmt && vf < vect_min_worthwhile_factor (code)))
|
||||
|| (!vec_stmt && !vect_worthwhile_without_simd_p (vinfo, code)))
|
||||
return false;
|
||||
if (dump_enabled_p ())
|
||||
dump_printf_loc (MSG_NOTE, vect_location,
|
||||
|
@ -5424,7 +5412,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi,
|
|||
/* Worthwhile without SIMD support? Check only during analysis. */
|
||||
if (!VECTOR_MODE_P (vec_mode)
|
||||
&& !vec_stmt
|
||||
&& vf < vect_min_worthwhile_factor (code))
|
||||
&& !vect_worthwhile_without_simd_p (vinfo, code))
|
||||
{
|
||||
if (dump_enabled_p ())
|
||||
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
|
||||
|
|
|
@ -1230,7 +1230,7 @@ extern bool vectorizable_reduction (gimple *, gimple_stmt_iterator *,
|
|||
extern bool vectorizable_induction (gimple *, gimple_stmt_iterator *,
|
||||
gimple **, slp_tree);
|
||||
extern tree get_initial_def_for_reduction (gimple *, tree, tree *);
|
||||
extern int vect_min_worthwhile_factor (enum tree_code);
|
||||
extern bool vect_worthwhile_without_simd_p (vec_info *, tree_code);
|
||||
extern int vect_get_known_peeling_cost (loop_vec_info, int, int *,
|
||||
stmt_vector_for_cost *,
|
||||
stmt_vector_for_cost *,
|
||||
|
|
Loading…
Add table
Reference in a new issue