diff options
author | Richard Biener <rguenther@suse.de> | 2021-11-15 11:37:56 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-11-15 13:07:57 +0100 |
commit | 220bd61874cf114667b44f9ded76ed0639eb278b (patch) | |
tree | e7fdc16ddcbe8866feed8fd504911e09024b0ddc /gcc/tree-vect-loop.c | |
parent | 4d281ff7ddd8f6365943c0a622107f92315bb8a6 (diff) | |
download | gcc-220bd61874cf114667b44f9ded76ed0639eb278b.zip gcc-220bd61874cf114667b44f9ded76ed0639eb278b.tar.gz gcc-220bd61874cf114667b44f9ded76ed0639eb278b.tar.bz2 |
tree-optimization/103237 - avoid vectorizing unhandled double reductions
Double reductions which have multiple LC PHIs in the inner loop
are not handled correctly during transformation since those PHIs
are not properly classified as reduction. The following disables
vectorizing them.
2021-11-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/103237
* tree-vect-loop.c (vect_is_simple_reduction): Fail for
double reductions with multiple inner loop LC PHI nodes.
* gcc.dg/torture/pr103237.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 1cd5dbc..73efdb9 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -3567,6 +3567,17 @@ vect_is_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info, return def_stmt_info; } + /* When the inner loop of a double reduction ends up with more than + one loop-closed PHI we have failed to classify alternate such + PHIs as double reduction, leading to wrong code. See PR103237. */ + if (inner_loop_of_double_reduc && lcphis.length () != 1) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "unhandle double reduction\n"); + return NULL; + } + /* If this isn't a nested cycle or if the nested cycle reduction value is used ouside of the inner loop we cannot handle uses of the reduction value. */ |