diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2018-03-18 10:25:29 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-03-18 10:25:29 +0000 |
commit | 928b965f29f587bb033555f0db646c94afe8e7ef (patch) | |
tree | 0e183b4538fea404815ada3c300fd059d50a5e8e /gcc/tree-vect-loop.c | |
parent | 4a8298b46d966bcc979bb170b32a163db235f1b5 (diff) | |
download | gcc-928b965f29f587bb033555f0db646c94afe8e7ef.zip gcc-928b965f29f587bb033555f0db646c94afe8e7ef.tar.gz gcc-928b965f29f587bb033555f0db646c94afe8e7ef.tar.bz2 |
Don't try to vectorise COND_EXPR reduction chains (PR 84913)
The testcase ICEd for both SVE and AVX512 because we were trying
to vectorise a chain of COND_EXPRs as a reduction and getting
confused by reduc_index == -1.
2018-03-18 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
PR tree-optimization/84913
* tree-vect-loop.c (vectorizable_reduction): Don't try to
vectorize chains of COND_EXPRs.
gcc/testsuite/
PR tree-optimization/84913
* gfortran.dg/vect/pr84913.f90: New test.
From-SVN: r258631
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 6585c85..7b3009a 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -6788,6 +6788,30 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, /* If we have a condition reduction, see if we can simplify it further. */ if (v_reduc_type == COND_REDUCTION) { + /* TODO: We can't yet handle reduction chains, since we need to treat + each COND_EXPR in the chain specially, not just the last one. + E.g. for: + + x_1 = PHI <x_3, ...> + x_2 = a_2 ? ... : x_1; + x_3 = a_3 ? ... : x_2; + + we're interested in the last element in x_3 for which a_2 || a_3 + is true, whereas the current reduction chain handling would + vectorize x_2 as a normal VEC_COND_EXPR and only treat x_3 + as a reduction operation. */ + if (reduc_index == -1) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "conditional reduction chains not supported\n"); + return false; + } + + /* vect_is_simple_reduction ensured that operand 2 is the + loop-carried operand. */ + gcc_assert (reduc_index == 2); + /* Loop peeling modifies initial value of reduction PHI, which makes the reduction stmt to be transformed different to the original stmt analyzed. We need to record reduction code for |