aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-09-15 10:20:34 +0200
committerRichard Biener <rguenther@suse.de>2021-09-15 11:13:21 +0200
commitb6d8fa66e1bf08756cb4134735b5034e171f49d1 (patch)
treea3c40c775922f33cc28c3dafb3ffacb4b3fee4f7 /gcc/tree-vect-loop.c
parentcc1e28878a228b6c4a0872e56d97ac88971b7725 (diff)
downloadgcc-b6d8fa66e1bf08756cb4134735b5034e171f49d1.zip
gcc-b6d8fa66e1bf08756cb4134735b5034e171f49d1.tar.gz
gcc-b6d8fa66e1bf08756cb4134735b5034e171f49d1.tar.bz2
tree-optimization/102318 - reduction epilogue re-use
This refines the fix for PR102226 to do the mode conversion from V2DI to VNx2DI separately from the sign-conversion, retaining the signedness of the saved accumulator as before the original fix. 2021-09-15 Richard Biener <rguenther@suse.de> PR tree-optimization/102318 * tree-vect-loop.c (vect_transform_cycle_phi): Revert previous change and do the mode conversion separately from the sign conversion. * gcc.dg/vect/pr102318.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index c9dcc64..5a5b8da 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7755,11 +7755,20 @@ vect_transform_cycle_phi (loop_vec_info loop_vinfo,
(reduc_info),
&stmts);
}
- if (!useless_type_conversion_p (vectype_out, TREE_TYPE (def)))
- def = gimple_convert (&stmts, vectype_out, def);
+ /* The epilogue loop might use a different vector mode, like
+ VNx2DI vs. V2DI. */
+ if (TYPE_MODE (vectype_out) != TYPE_MODE (TREE_TYPE (def)))
+ {
+ tree reduc_type = build_vector_type_for_mode
+ (TREE_TYPE (TREE_TYPE (def)), TYPE_MODE (vectype_out));
+ def = gimple_convert (&stmts, reduc_type, def);
+ }
/* Adjust the input so we pick up the partially reduced value
for the skip edge in vect_create_epilog_for_reduction. */
accumulator->reduc_input = def;
+ /* And the reduction could be carried out using a different sign. */
+ if (!useless_type_conversion_p (vectype_out, TREE_TYPE (def)))
+ def = gimple_convert (&stmts, vectype_out, def);
if (loop_vinfo->main_loop_edge)
{
/* While we'd like to insert on the edge this will split