From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 6E3443846024; Fri, 3 May 2024 13:55:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E3443846024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714744526; bh=LjsTolHy9mPNidV9SZpjRo3BHfRQtEZZFMardj26R0k=; h=From:To:Subject:Date:From; b=x17zYOhMzijOHthL1sCd7UMgWsuSjVbfwF4I5MX0WBQV8aflMcjOagwYxGvbSjqUX w4xzian+QeLRJ7yUhhgVTO2fsKyF7a73Iy75JDIDtTFa4GjjZu3zbLecSUlUahU5KV z3mpfszKvbuRhk3Q9SVB1bQkfCRf2QWo7QU3Yzgg= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-8683] tree-optimization/114736 - SLP DFS walk issue X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 5a3cc62dbb45185dd1ca32caec80d57a320ec5a0 X-Git-Newrev: 0624852a3ea684f6b9dabea864bcb45e31304728 Message-Id: <20240503135526.6E3443846024@sourceware.org> Date: Fri, 3 May 2024 13:55:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0624852a3ea684f6b9dabea864bcb45e31304728 commit r13-8683-g0624852a3ea684f6b9dabea864bcb45e31304728 Author: Richard Biener Date: Tue Apr 16 11:33:48 2024 +0200 tree-optimization/114736 - SLP DFS walk issue 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. 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. (cherry picked from commit f949481a1f7ab973608a4ffcc0e342ab5a74e8e4) Diff: --- gcc/testsuite/gfortran.dg/vect/pr114736.f90 | 14 ++++++++++++++ gcc/tree-vect-slp.cc | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) 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 e4d3cb89e6f..a72dd787a34 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -4126,7 +4126,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;