public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/114736 - SLP DFS walk issue
@ 2024-04-16 10:36 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-04-16 10:36 UTC (permalink / raw)
  To: gcc-patches

The following fixes a DFS walk issue when identifying to be ignored
latch edges.  We have (bogus) SLP_TREE_REPRESENTATIVEs for VEC_PERM
nodes so those have to be explicitly ignored as possibly being PHIs.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

Richard.

	PR tree-optimization/114736
	* tree-vect-slp.cc (vect_optimize_slp_pass::is_cfg_latch_edge):
	Do not consider VEC_PERM_EXPRs as PHI use.

	* gfortran.dg/vect/pr114736.f90: New testcase.
---
 gcc/testsuite/gfortran.dg/vect/pr114736.f90 | 14 ++++++++++++++
 gcc/tree-vect-slp.cc                        |  3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/vect/pr114736.f90

diff --git a/gcc/testsuite/gfortran.dg/vect/pr114736.f90 b/gcc/testsuite/gfortran.dg/vect/pr114736.f90
new file mode 100644
index 00000000000..cdbfb6f415a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/pr114736.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-additional-options "-O3" }
+
+SUBROUTINE MY_ROUTINE (N, A, B )
+IMPLICIT NONE
+INTEGER,   INTENT(IN)    :: N
+COMPLEX,   INTENT(IN)    :: A(N)
+COMPLEX,   INTENT(OUT)   :: B(N)
+INTEGER                  :: II
+B(:) = (1.,0.)
+DO II = 1, N-1
+    B(II) = A(N-II+1) / A(N-II)
+ENDDO
+END SUBROUTINE MY_ROUTINE
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 2e5481acbc7..109f318c7d6 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -4328,7 +4328,8 @@ vect_optimize_slp_pass::is_cfg_latch_edge (graph_edge *ud)
 {
   slp_tree use = m_vertices[ud->src].node;
   slp_tree def = m_vertices[ud->dest].node;
-  if (SLP_TREE_DEF_TYPE (use) != vect_internal_def
+  if ((SLP_TREE_DEF_TYPE (use) != vect_internal_def
+       || SLP_TREE_CODE (use) == VEC_PERM_EXPR)
       || SLP_TREE_DEF_TYPE (def) != vect_internal_def)
     return false;
 
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-16 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 10:36 [PATCH] tree-optimization/114736 - SLP DFS walk issue Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).