From 2e7a4f579b1157754ea20a03431b4fa80cd4567a Mon Sep 17 00:00:00 2001 From: Andre Vieira Date: Wed, 6 Nov 2019 11:22:35 +0000 Subject: [PATCH] [vect] PR92317: fix skip_epilogue creation for epilogues gcc/ChangeLog: 2019-11-06 Andre Vieira PR tree-optimization/92317 * tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard2): Also update phi's with constant phi arguments. gcc/testsuite/ChangeLog: 2019-11-06 Andre Vieira PR tree-optimization/92317 * gcc/testsuite/g++.dg/opt/pr92317.C: New test. From-SVN: r277877 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/g++.dg/opt/pr92317.C | 51 ++++++++++++++++++++++++++++++ gcc/tree-vect-loop-manip.c | 12 ++++--- 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr92317.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 897b4945172..e74c57aaf13 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-11-06 Andre Vieira + + PR tree-optimization/92317 + * tree-vect-loop-manip.c (slpeel_update_phi_nodes_for_guard2): Also + update phi's with constant phi arguments. + 2019-11-06 Eric Botcazou Alexandre Oliva diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 64568e5661a..b7fb5ce3a92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-06 Andre Vieira + + PR tree-optimization/92317 + * gcc/testsuite/g++.dg/opt/pr92317.C: New test. + 2019-11-06 Gergö Barany Frederik Harwath Thomas Schwinge diff --git a/gcc/testsuite/g++.dg/opt/pr92317.C b/gcc/testsuite/g++.dg/opt/pr92317.C new file mode 100644 index 00000000000..2bb9729fc96 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr92317.C @@ -0,0 +1,51 @@ +// Copied from pr87967.C +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -ftree-vectorize -fno-tree-pre --param vect-epilogues-nomask=1" } + +void h(); +template struct k { using d = b; }; +template class> using e = k; +template class f> +using g = typename e::d; +struct l { + template using ab = typename i::j; +}; +struct n : l { + using j = g; +}; +class o { +public: + long r(); +}; +char m; +char s() { + if (m) + return '0'; + return 'A'; +} +class t { +public: + typedef char *ad; + ad m_fn2(); +}; +void fn3() { + char *a; + t b; + bool p = false; + while (*a) { + h(); + o c; + if (*a) + a++; + if (c.r()) { + n::j q; + for (t::ad d = b.m_fn2(), e; d != e; d++) { + char f = *q; + *d = f + s(); + } + p = true; + } + } + if (p) + throw; +} diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c index 1fbcaf2676f..54f3ccf3ec3 100644 --- a/gcc/tree-vect-loop-manip.c +++ b/gcc/tree-vect-loop-manip.c @@ -2291,12 +2291,14 @@ slpeel_update_phi_nodes_for_guard2 (class loop *loop, class loop *epilog, { gphi *update_phi = gsi.phi (); tree old_arg = PHI_ARG_DEF (update_phi, 0); - /* This loop-closed-phi actually doesn't represent a use out of the - loop - the phi arg is a constant. */ - if (TREE_CODE (old_arg) != SSA_NAME) - continue; - tree merge_arg = get_current_def (old_arg); + tree merge_arg = NULL_TREE; + + /* If the old argument is a SSA_NAME use its current_def. */ + if (TREE_CODE (old_arg) == SSA_NAME) + merge_arg = get_current_def (old_arg); + /* If it's a constant or doesn't have a current_def, just use the old + argument. */ if (!merge_arg) merge_arg = old_arg; -- 2.30.2