diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2020-01-22 18:21:05 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2020-01-28 11:06:43 +0000 |
commit | 1e26ff7391c54c6d30760aea427b6bc2bdb46124 (patch) | |
tree | 426722890ce5b7cdb4f2e2f754bb53ed4e353a90 | |
parent | 627d59b6b3062de921fbdd80b2b48de18f599d03 (diff) | |
download | gcc-1e26ff7391c54c6d30760aea427b6bc2bdb46124.zip gcc-1e26ff7391c54c6d30760aea427b6bc2bdb46124.tar.gz gcc-1e26ff7391c54c6d30760aea427b6bc2bdb46124.tar.bz2 |
vect: Pattern-matched calls in reduction chains
gcc.dg/pr56350.c started ICEing for SVE in GCC 10 because we
pattern-matched a division reduction:
a /= 8;
into a signed shift with division semantics:
... = IFN_SDIV_POW2 (..., 3);
whereas the reduction code expected it still to be a gassign.
One fix would be to check for a reduction in the pattern matcher
(but current patterns don't generally do that). Another would be
to fail gracefully for reductions involving calls. Since we can't
vectorise the reduction either way, and probably have a better shot
with the shift form, this patch goes for the "fail gracefully" approach.
2020-01-28 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-vect-loop.c (vectorizable_reduction): Fail gracefully
for reduction chains that (now) include a call.
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 14 |
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f5ec70..4d6ceb6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2020-01-28 Richard Sandiford <richard.sandiford@arm.com> + * tree-vect-loop.c (vectorizable_reduction): Fail gracefully + for reduction chains that (now) include a call. + +2020-01-28 Richard Sandiford <richard.sandiford@arm.com> + PR tree-optimization/92822 * tree-ssa-forwprop.c (simplify_vector_constructor): When filling out the don't-care elements of a vector whose significant elements diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index b4cfad8..53fccb7 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -6026,10 +6026,18 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node, info_for_reduction to work. */ if (STMT_VINFO_LIVE_P (vdef)) STMT_VINFO_REDUC_DEF (def) = phi_info; - if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (vdef->stmt))) + gassign *assign = dyn_cast <gassign *> (vdef->stmt); + if (!assign) { - if (!tree_nop_conversion_p (TREE_TYPE (gimple_assign_lhs (vdef->stmt)), - TREE_TYPE (gimple_assign_rhs1 (vdef->stmt)))) + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "reduction chain includes calls.\n"); + return false; + } + if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (assign))) + { + if (!tree_nop_conversion_p (TREE_TYPE (gimple_assign_lhs (assign)), + TREE_TYPE (gimple_assign_rhs1 (assign)))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, |