diff options
author | Richard Biener <rguenther@suse.de> | 2024-06-27 11:26:08 +0200 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2024-06-27 14:11:32 +0200 |
commit | 7886830bb45c4f5dca0496d4deae9a45204d78f5 (patch) | |
tree | f84084174dd67d75c5fc2b1fdb4d914478209035 /gcc | |
parent | 73ad57c244c283bf6da0c16630212f11b945eda5 (diff) | |
download | gcc-7886830bb45c4f5dca0496d4deae9a45204d78f5.zip gcc-7886830bb45c4f5dca0496d4deae9a45204d78f5.tar.gz gcc-7886830bb45c4f5dca0496d4deae9a45204d78f5.tar.bz2 |
tree-optimization/115669 - fix SLP reduction association
The following avoids associating a reduction path as that might
get STMT_VINFO_REDUC_IDX out-of-sync with the SLP operand order.
This is a latent issue with SLP reductions but now easily exposed
as we're doing single-lane SLP reductions.
When we achieved SLP only we can move and update this meta-data.
PR tree-optimization/115669
* tree-vect-slp.cc (vect_build_slp_tree_2): Do not reassociate
chains that participate in a reduction.
* gcc.dg/vect/pr115669.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/pr115669.c | 22 | ||||
-rw-r--r-- | gcc/tree-vect-slp.cc | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr115669.c b/gcc/testsuite/gcc.dg/vect/pr115669.c new file mode 100644 index 0000000..361a17a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr115669.c @@ -0,0 +1,22 @@ +/* { dg-additional-options "-fwrapv" } */ + +#include "tree-vect.h" + +int a = 10; +unsigned b; +long long c[100]; +int foo() +{ + long long *d = c; + for (short e = 0; e < a; e++) + b += ~(d ? d[e] : 0); + return b; +} + +int main() +{ + check_vect (); + if (foo () != -10) + abort (); + return 0; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 1252b61..174b480 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -2069,6 +2069,9 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, else if (is_a <loop_vec_info> (vinfo) /* ??? We don't handle !vect_internal_def defs below. */ && STMT_VINFO_DEF_TYPE (stmt_info) == vect_internal_def + /* ??? Do not associate a reduction, this will wreck REDUC_IDX + mapping as long as that exists on the stmt_info level. */ + && STMT_VINFO_REDUC_IDX (stmt_info) == -1 && is_gimple_assign (stmt_info->stmt) && (associative_tree_code (gimple_assign_rhs_code (stmt_info->stmt)) || gimple_assign_rhs_code (stmt_info->stmt) == MINUS_EXPR) |