Message ID | D386D537.10263%alan.hayward@arm.com |
---|---|
State | New |
Headers | show |
On Wed, Jun 15, 2016 at 10:49 AM, Alan Hayward <alan.hayward@arm.com> wrote: > For a PHI to be used outside the loop it needs to be vectorized. However > the > vectorizer currently will only vectorize PHIs that are an induction. > > This patch fixes PR 71439 by only allowing a live PHI to be vectorized if > it > is an induction. In addition, live PHIs need to pass a > vectorizable_live_operation check. > > Tested on x86 and aarch64. > Ok to commit? Ok. Thanks, Richard. > Alan. > > gcc/ > PR tree-optimization/71439 > * tree-vect-loop.c (vect_analyze_loop_operations): Additional check for > live PHIs. > > testsuite/ > PR tree-optimization/71439 > * gcc.dg/vect/pr71439.c: New > > > > diff --git a/gcc/testsuite/gcc.dg/vect/pr71439.c > b/gcc/testsuite/gcc.dg/vect/pr71439.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..95e4763bad6e9f301d53c20ffa160b96b > dad9a53 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/vect/pr71439.c > @@ -0,0 +1,17 @@ > +#include "tree-vect.h" > + > +int a, b, c; > +short fn1(int p1, int p2) { return p1 + p2; } > + > +int main() { > + a = 0; > + for (; a < 30; a = fn1(a, 4)) { > + c = b; > + b = 6; > + } > + > + if (c != 6) > + abort (); > + > + return 0; > +} > diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c > index > 1231b95f6a71337833e8c4b24884da9f96a7b5bf..90ade75bcd212b542ad680877a79df717 > 751ff4b 100644 > --- a/gcc/tree-vect-loop.c > +++ b/gcc/tree-vect-loop.c > @@ -1669,7 +1669,8 @@ vect_analyze_loop_operations (loop_vec_info > loop_vinfo) > > gcc_assert (stmt_info); > > - if (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_scope > + if ((STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_scope > + || STMT_VINFO_LIVE_P (stmt_info)) > && STMT_VINFO_DEF_TYPE (stmt_info) != vect_induction_def) > { > /* A scalar-dependence cycle that we don't support. */ > @@ -1686,6 +1687,9 @@ vect_analyze_loop_operations (loop_vec_info > loop_vinfo) > ok = vectorizable_induction (phi, NULL, NULL); > } > > + if (ok && STMT_VINFO_LIVE_P (stmt_info)) > + ok = vectorizable_live_operation (phi, NULL, NULL, -1, NULL); > + > if (!ok) > { > if (dump_enabled_p ()) > > > >
diff --git a/gcc/testsuite/gcc.dg/vect/pr71439.c b/gcc/testsuite/gcc.dg/vect/pr71439.c new file mode 100644 index 0000000000000000000000000000000000000000..95e4763bad6e9f301d53c20ffa160b96b dad9a53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr71439.c @@ -0,0 +1,17 @@ +#include "tree-vect.h" + +int a, b, c; +short fn1(int p1, int p2) { return p1 + p2; } + +int main() { + a = 0; + for (; a < 30; a = fn1(a, 4)) { + c = b; + b = 6; + } + + if (c != 6) + abort (); + + return 0; +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 1231b95f6a71337833e8c4b24884da9f96a7b5bf..90ade75bcd212b542ad680877a79df717 751ff4b 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1669,7 +1669,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) gcc_assert (stmt_info); - if (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_scope + if ((STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_scope + || STMT_VINFO_LIVE_P (stmt_info)) && STMT_VINFO_DEF_TYPE (stmt_info) != vect_induction_def) {