From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 03A7B3858011 for ; Tue, 6 Sep 2022 08:55:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 03A7B3858011 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C546C1F977 for ; Tue, 6 Sep 2022 08:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662454516; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=zP8vmvumrEHwON+b6Bxhgrs12fLmoTfT6VI0OdojN0E=; b=kyaT4g87y17a9+tbCas0mhS6YIb9iVsY9ZgHeFoRge+TMd0oZt+yJXItnfRXflP4AbYtWY WUolHv17XYT/bQTyRZ352zfXhQWEuqhT1ZiWQmlTVAJWWNFvpSYuokDCJ2hcbWtJoiCp5j 5eQwB+WqbmdryU/7qFW7DMbLGQ76KHQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662454516; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=zP8vmvumrEHwON+b6Bxhgrs12fLmoTfT6VI0OdojN0E=; b=GhDDNvPpjIiqQ+TNb4C5+Lxx+R8T1KlT6FLAheA4KiNvmpkuOx2nh+H6KvsjU7u6LGzX7P /BhN6jnnLcy2q0AQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id BEE172C141 for ; Tue, 6 Sep 2022 08:55:16 +0000 (UTC) Date: Tue, 6 Sep 2022 08:55:16 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106841 - gather and hybrid SLP User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20220906085516.-vRP9lTjU7SM3GqR7eQJHE67bAsPdXTjyEDiKejZKAw@z> Hybrid SLP detection currently fails to consider a not direct offset operand of a scatter/gather operation. The following fixes this. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106841 * tree-vect-slp.cc (vect_detect_hybrid_slp): Also process scatter/gather offset. * g++.dg/vect/pr106841.cc: New testcase. --- gcc/testsuite/g++.dg/vect/pr106841.cc | 52 +++++++++++++++++++++++++++ gcc/tree-vect-slp.cc | 9 +++++ 2 files changed, 61 insertions(+) create mode 100644 gcc/testsuite/g++.dg/vect/pr106841.cc 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 b10f69da133..3fa2dc96dda 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -5799,6 +5799,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); + } } } -- 2.35.3