Make fix for PR 83965 handle SLP reduction chains
This patch prevents pattern-matching of fold-left SLP reduction chains, which the previous patch for 83965 didn't handle properly. It only stops the last statement in the group from being matched, but that's enough to cause the group to be dissolved later. A better fix would be to put all the information about the reduction on the the first statement in the reduction chain, so that every statement in the group can tell what the group is doing. That doesn't seem like stage 4 material though. 2018-02-26 Richard Sandiford <richard.sandiford@linaro.org> gcc/ PR tree-optimization/83965 * tree-vect-patterns.c (vect_reassociating_reduction_p): Assume that grouped statements are part of a reduction chain. Return true if the statement is not marked as a reduction itself but is part of a group. (vect_recog_dot_prod_pattern): Don't check whether the statement is part of a group here. (vect_recog_sad_pattern): Likewise. (vect_recog_widen_sum_pattern): Likewise. gcc/testsuite/ PR tree-optimization/83965 * gcc.dg/vect/pr83965-2.c: New test. From-SVN: r257995
This commit is contained in:
parent
9992661cc6
commit
d99dcb77bb
@ -1,3 +1,15 @@
|
||||
2018-02-26 Richard Sandiford <richard.sandiford@linaro.org>
|
||||
|
||||
PR tree-optimization/83965
|
||||
* tree-vect-patterns.c (vect_reassociating_reduction_p): Assume
|
||||
that grouped statements are part of a reduction chain. Return
|
||||
true if the statement is not marked as a reduction itself but
|
||||
is part of a group.
|
||||
(vect_recog_dot_prod_pattern): Don't check whether the statement
|
||||
is part of a group here.
|
||||
(vect_recog_sad_pattern): Likewise.
|
||||
(vect_recog_widen_sum_pattern): Likewise.
|
||||
|
||||
2018-02-26 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
PR debug/84545
|
||||
|
@ -1,3 +1,8 @@
|
||||
2018-02-26 Richard Sandiford <richard.sandiford@linaro.org>
|
||||
|
||||
PR tree-optimization/83965
|
||||
* gcc.dg/vect/pr83965-2.c: New test.
|
||||
|
||||
2018-02-26 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
* gcc.c-torture/compile/regs-arg-size.c (swprintf): Declare.
|
||||
|
16
gcc/testsuite/gcc.dg/vect/pr83965-2.c
Normal file
16
gcc/testsuite/gcc.dg/vect/pr83965-2.c
Normal file
@ -0,0 +1,16 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-additional-options "-Ofast -ftrapv" } */
|
||||
|
||||
int c;
|
||||
unsigned char d;
|
||||
int e (unsigned char *f)
|
||||
{
|
||||
int g;
|
||||
for (int a; a; a++)
|
||||
{
|
||||
for (int b = 0; b < 6; b++)
|
||||
g += __builtin_abs (f[b] - d);
|
||||
f += c;
|
||||
}
|
||||
return g;
|
||||
}
|
@ -222,13 +222,16 @@ vect_recog_temp_ssa_var (tree type, gimple *stmt)
|
||||
}
|
||||
|
||||
/* Return true if STMT_VINFO describes a reduction for which reassociation
|
||||
is allowed. */
|
||||
is allowed. If STMT_INFO is part of a group, assume that it's part of
|
||||
a reduction chain and optimistically assume that all statements
|
||||
except the last allow reassociation. */
|
||||
|
||||
static bool
|
||||
vect_reassociating_reduction_p (stmt_vec_info stmt_vinfo)
|
||||
{
|
||||
return (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def
|
||||
&& STMT_VINFO_REDUC_TYPE (stmt_vinfo) != FOLD_LEFT_REDUCTION);
|
||||
? STMT_VINFO_REDUC_TYPE (stmt_vinfo) != FOLD_LEFT_REDUCTION
|
||||
: GROUP_FIRST_ELEMENT (stmt_vinfo) != NULL);
|
||||
}
|
||||
|
||||
/* Function vect_recog_dot_prod_pattern
|
||||
@ -350,8 +353,7 @@ vect_recog_dot_prod_pattern (vec<gimple *> *stmts, tree *type_in,
|
||||
{
|
||||
gimple *def_stmt;
|
||||
|
||||
if (!vect_reassociating_reduction_p (stmt_vinfo)
|
||||
&& ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
|
||||
if (!vect_reassociating_reduction_p (stmt_vinfo))
|
||||
return NULL;
|
||||
oprnd0 = gimple_assign_rhs1 (last_stmt);
|
||||
oprnd1 = gimple_assign_rhs2 (last_stmt);
|
||||
@ -571,8 +573,7 @@ vect_recog_sad_pattern (vec<gimple *> *stmts, tree *type_in,
|
||||
{
|
||||
gimple *def_stmt;
|
||||
|
||||
if (!vect_reassociating_reduction_p (stmt_vinfo)
|
||||
&& ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
|
||||
if (!vect_reassociating_reduction_p (stmt_vinfo))
|
||||
return NULL;
|
||||
plus_oprnd0 = gimple_assign_rhs1 (last_stmt);
|
||||
plus_oprnd1 = gimple_assign_rhs2 (last_stmt);
|
||||
@ -1256,8 +1257,7 @@ vect_recog_widen_sum_pattern (vec<gimple *> *stmts, tree *type_in,
|
||||
if (gimple_assign_rhs_code (last_stmt) != PLUS_EXPR)
|
||||
return NULL;
|
||||
|
||||
if (!vect_reassociating_reduction_p (stmt_vinfo)
|
||||
&& ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo))
|
||||
if (!vect_reassociating_reduction_p (stmt_vinfo))
|
||||
return NULL;
|
||||
|
||||
oprnd0 = gimple_assign_rhs1 (last_stmt);
|
||||
|
Loading…
Reference in New Issue
Block a user