From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 87BAF3857428; Fri, 9 Sep 2022 09:49:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87BAF3857428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662716999; bh=izU6mctOskoNlWr+xluepFlG2ipN2uzG8RhzPs9o3ZA=; h=From:To:Subject:Date:From; b=bYxWJ5D+DnWMUPnjLEKCa+vuTigMnc+vD1OTFFjd3py3ioHw4p4hhU6479F6+5iOH y5wAcxH2wk32BZlcukp/i2huuWJ5j4NdJJ9/ZWVLm/cNX5mwWUnNbaij1OLl5Pfw7W 5GKP9caRsW/MnhwKAhdyxeO1MDj6QErAMDRoTaP4= 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 r12-8752] tree-optimization/106841 - gather and hybrid SLP X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: e08dd36f90e74cd5be615b1ca82a38896434d48c X-Git-Newrev: 41b4faa130a32b37debb1f92e3fa93b2fe8571fc Message-Id: <20220909094959.87BAF3857428@sourceware.org> Date: Fri, 9 Sep 2022 09:49:59 +0000 (GMT) List-Id: https://gcc.gnu.org/g:41b4faa130a32b37debb1f92e3fa93b2fe8571fc commit r12-8752-g41b4faa130a32b37debb1f92e3fa93b2fe8571fc Author: Richard Biener Date: Tue Sep 6 10:08:44 2022 +0200 tree-optimization/106841 - gather and hybrid SLP Hybrid SLP detection currently fails to consider a not direct offset operand of a scatter/gather operation. The following fixes this. PR tree-optimization/106841 * tree-vect-slp.cc (vect_detect_hybrid_slp): Also process scatter/gather offset. * g++.dg/vect/pr106841.cc: New testcase. (cherry picked from commit e33e61d417eb5e981bb7d709f8681a2f55ed518a) Diff: --- gcc/testsuite/g++.dg/vect/pr106841.cc | 52 +++++++++++++++++++++++++++++++++++ gcc/tree-vect-slp.cc | 9 ++++++ 2 files changed, 61 insertions(+) diff --git a/gcc/testsuite/g++.dg/vect/pr106841.cc b/gcc/testsuite/g++.dg/vect/pr106841.cc new file mode 100644 index 00000000000..7458bc15a25 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr106841.cc @@ -0,0 +1,52 @@ +// { dg-do compile } +// { dg-additional-options "-O3 -ffast-math" } +// { dg-additional-options "-march=bdver2" { target x86_64-*-* } } + +struct R3 { + double z; + R3(R3 A, R3 B) : z(B.z - A.z) {} + double norme() { return z; } +}; +struct TBoundaryEdge { + int *vertices[2]; + int &operator[](int i) { return *vertices[i]; } +}; +struct Mesh { + int vertices; + TBoundaryEdge *bedges; + int operator()(int &vv) { return &vv - &vertices; } + TBoundaryEdge be(int i) { return bedges[i]; } +}; +template struct GenericElement { + typedef typename Data::V Vertex; + static const int nv = Data::NbOfVertices; + Vertex *vertices[nv]; + double mes; + void set(int *iv, Vertex *v0) { + for (int i = 0; i < nv; ++i) + vertices[i] = v0 + iv[i]; + mes = Data::mesure(vertices); + } +}; +struct DataSeg3 { + static const int NbOfVertices = 2; + typedef R3 V; + static double mesure(V *pv[]) { return R3(*pv[0], *pv[1]).norme(); } +}; +struct MeshS { + MeshS(); +}; +template struct Movemesh_Op { void foo(Mesh, DataSeg3::V *) const; }; +template <> void Movemesh_Op::foo(Mesh pTh, DataSeg3::V *v0) const { + GenericElement *bS = new GenericElement[8]; + for (int ibe = 0; ibe < 8; ibe++) { + TBoundaryEdge K(pTh.be(ibe)); + int iv[2]; + for (int i = 0; i < 2; i++) { + int &__trans_tmp_2 = K[i]; + iv[i] = pTh(__trans_tmp_2); + } + bS[ibe].set(iv, v0); + } + MeshS T_Th; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index b89a417711b..0223056a186 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -4387,6 +4387,15 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo) to use walk_gimple_op. */ wi.is_lhs = 0; walk_gimple_op (stmt_info->stmt, vect_detect_hybrid_slp, &wi); + /* For gather/scatter make sure to walk the offset operand, that + can be a scaling and conversion away. */ + gather_scatter_info gs_info; + if (STMT_VINFO_GATHER_SCATTER_P (stmt_info) + && vect_check_gather_scatter (stmt_info, loop_vinfo, &gs_info)) + { + int dummy; + vect_detect_hybrid_slp (&gs_info.offset, &dummy, &wi); + } } }