diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2018-08-22 13:02:39 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2018-08-22 13:02:39 +0000 |
commit | 3a4da26602da1bd30c4ff2793fed480f180248c1 (patch) | |
tree | fc168da2cf5421fba469e6139e74375a1579bf2d /gcc | |
parent | 203942b8af64926d787b4a545184866f9572978d (diff) | |
download | gcc-3a4da26602da1bd30c4ff2793fed480f180248c1.zip gcc-3a4da26602da1bd30c4ff2793fed480f180248c1.tar.gz gcc-3a4da26602da1bd30c4ff2793fed480f180248c1.tar.bz2 |
[1/2] Fix bogus double reduction (PR 86725)
This patch is the first part of the fix for PR 86725. We would
treat x_1 in:
outer1:
x_1 = PHI <x_4(outer2), ...>;
...
inner:
x_2 = ...x_1...;
...
x_3 = ...;
...
outer2:
x_4 = PHI <x_3(inner)>;
...
as a double reduction without checking what kind of statement x_2 is.
In practice it has to be a phi, since for other x_2, x_1 would simply
be a loop invariant that gets used for every inner loop iteration.
The idea with doing this patch first is that, by checking x_2 really
is a phi, we can hand off the validation of the rest of the reduction
to the phi analysis in the inner loop.
The test case is a variant of the one in the PR.
2018-08-22 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR tree-optimization/86725
* tree-vect-loop.c (vect_is_simple_reduction): When treating
an outer loop phi as a double reduction, make sure that the
single user of the phi result is an inner loop phi.
gcc/testsuite/
PR tree-optimization/86725
* gcc.dg/vect/no-scevccp-pr86725-1.c: New test.
From-SVN: r263773
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/no-scevccp-pr86725-1.c | 26 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 1 |
4 files changed, 39 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6fdb1b6..63779d3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2018-08-22 Richard Sandiford <richard.sandiford@arm.com> + PR tree-optimization/86725 + * tree-vect-loop.c (vect_is_simple_reduction): When treating + an outer loop phi as a double reduction, make sure that the + single user of the phi result is an inner loop phi. + +2018-08-22 Richard Sandiford <richard.sandiford@arm.com> + * tree-vect-data-refs.c (vect_analyze_group_access_1): Convert grouped stores with gaps to a strided group. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9c624ff..3117afa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2018-08-22 Richard Sandiford <richard.sandiford@arm.com> + PR tree-optimization/86725 + * gcc.dg/vect/no-scevccp-pr86725-1.c: New test. + +2018-08-22 Richard Sandiford <richard.sandiford@arm.com> + * gcc.dg/vect/vect-avg-16.c: New test. * gcc.dg/vect/slp-37.c: Expect the loop to be vectorized. * gcc.dg/vect/vect-strided-u8-i8-gap4.c, diff --git a/gcc/testsuite/gcc.dg/vect/no-scevccp-pr86725-1.c b/gcc/testsuite/gcc.dg/vect/no-scevccp-pr86725-1.c new file mode 100644 index 0000000..3bc63a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-scevccp-pr86725-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O -w" } */ + +int foo; +int +nr (int xe, int z) +{ + int oo, wo = 0; + + for (oo = 0; oo < 4; ++oo) + { + int qq; + + int old_wo = wo; + for (qq = 0; qq < 2; ++qq) + { + wo = z + qq + old_wo; + xe += wo; + } + } + foo = wo; + return xe; +} + +/* { dg-final { scan-tree-dump-not "double reduction: wo" "vect" } } */ +/* { dg-final { scan-tree-dump-not "OUTER LOOP VECTORIZED" "vect" } } */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index db92f76..f21d995 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2992,6 +2992,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, stmt_vec_info phi_info, && loop->inner && flow_bb_inside_loop_p (loop->inner, gimple_bb (def1)) && is_gimple_assign (def1) + && is_a <gphi *> (phi_use_stmt) && flow_bb_inside_loop_p (loop->inner, gimple_bb (phi_use_stmt))) { if (dump_enabled_p ()) |