From patchwork Thu Oct 26 11:50:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 158509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp610338vqb; Thu, 26 Oct 2023 04:50:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4rxc2h8pi+DDk84EnDD9Ypdzqyt+1FE4eisI4M3NLmvHfJmmSwyOS86wI8L4Yc9ig6Vxu X-Received: by 2002:ac8:5ccc:0:b0:41e:204b:f947 with SMTP id s12-20020ac85ccc000000b0041e204bf947mr13764098qta.62.1698321053205; Thu, 26 Oct 2023 04:50:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698321053; cv=pass; d=google.com; s=arc-20160816; b=i2119NyXnvP4X3eMAr8fKeGoNJ7Bbwsfam59ysuxG7VQ7PkNcuwG4Y7pa1Au90DPDU WV65lHi2OsZOfCSM8v4hge1EG5I8DLzSb95V5Usg/CnXT0IvcDBbkkWInhZ6HVuOpF8B ocgWrHHg5DQsaVOefZfggrBQoVAv7AAnTxZ1ND882+OUqOf+60vl3W1KhhGA3s/5wVj3 aX/wNDbXuyQnsb5kKsgxhtg7rFdJvhh0UoKLIJ+I4kk9uKnBowi2LmHxgGEl9cVejkdC IAH0MAC3cgaDFA5N1DFW5Bn1Iv77Oe6M3nnmyLG/Fy/zTEYfiMkuv9Lf0vWL7KWlZBnY VmDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:arc-filter:dmarc-filter:delivered-to; bh=qi5ChKMvTfa18P8uBVG6HF3ZsGcA0GxLtp6l9YSpUvY=; fh=Hxj0cw/2jAkyitv6gv3v4BQlApRvZwleU4172JThTNQ=; b=LqsF8858wibfoBFCLW3ml6LjbZ4ZTl2Y/oiF3iOhuQW2rZyfZImxRhiC5UU9ZhfSZX 52VFrUFCe8X2gaKiLf7hSeem3fjs8uCpnAPPVFzH8I3Z22Gn8Qil4EJmVnfY6ncmHBm2 IONqGWuv5C5nnz8ggwpkNromRkHgIQlyWpnt8bq8y58BPl4omqA+eGTI6bMI3WqLMI9E CJmX4sGPJ6Jo8pff2GMMjcbv8Zgu/N4FVWbbLhH0lOufUPBSDDpZLMZb4srxwCbJrDWD Ugzj0aeNtS44fYZ6DvDnImJBYJj7xnzPtNrXdu0LjA5m/jVGKDvP5Ttr+Kku4DO1yRcb QS1w== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m18-20020a05622a119200b00417c0806678si9727095qtk.725.2023.10.26.04.50.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 04:50:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EFBD3385B512 for ; Thu, 26 Oct 2023 11:50:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by sourceware.org (Postfix) with ESMTPS id 801803858407 for ; Thu, 26 Oct 2023 11:50:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 801803858407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 801803858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=54.204.34.129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698321029; cv=none; b=p0OKEnsHQgp1/UDdlCF0+mNfyk222jBanD5/Q9JnEM4NApDWYh4rq8EF94RXZhR63lafFyfLtkIlJncUDloYOk/XaivkeCrV++xdr6hbbZC2rR3DifcmuddHQUn+AWo17O48LbmVdSfZx1DH07fT3VngRK+xMkasHX6sdZGGgCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698321029; c=relaxed/simple; bh=gZshzp11aHFzzFiQ4q6zTzF0RhUniLg5gmFdc7dVb/s=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=B2C1bVL8MTYI+/lBoQQIHj1QyBNeKEfXmlHMRdJSAfWKcRP3i9Oi5LeYqb11hx3wFK5QNFkXrdLVwUIbXkce7wZzELs7qvafFs2HPiovSoj9c9l39k/FE1wTVzD/WIX2FP1SDItpBVMqsKQZrgf8+aAnNe6fSV4wNzzrfRjXWE8= ARC-Authentication-Results: i=1; server2.sourceware.org X-QQ-mid: bizesmtp78t1698321021ts7gbu3h Received: from rios-cad122.hadoop.rioslab.org ( [58.60.1.26]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 26 Oct 2023 19:50:20 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: pPKMqzLgSARAFNIpMWwj07Yqx4tC2XDD8zpKxRiHzmQiPiQkfqJuKDM8nASWJ vQdV2QENb7LeFxmJWNlYYGr18W7CA6XbAFRo5/cbfCriTzZhmgCT48PUtfF3bjAHtE5aPnD WkcLkdcEv14EP1c1TFoAE2N7xBt6dGl1S2tpcQDKpjXvjtc36lxgVAKOmB/gk9nGmI1i/yD ANM5LgvAcjehmHAHhz97f5PvLkZVjCcSrt8jZlBoEO7SkHKknSMwWyNF/Qln0eTYrTyIhuU YPh4P8BNQIQCRddJGjleLxF5LB5ahhRkekmmrzgZO+UCmPLmDduJH+VrBcsaqi71SFfoL3S YxGixM4CnAwNVksxLKsrlCkRYQHEBwbLGDT+xQ3auhkP3ChyX/3l+uz7f5Pl3N5pbZDkBcL Qp3hlJi6LRYFboO/aUpgIw== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9207050747259961476 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, rguenther@suse.de, Juzhe-Zhong Subject: [PATCH] VECT: Support SLP MASK_LEN_GATHER_LOAD with conditional mask Date: Thu, 26 Oct 2023 19:50:19 +0800 Message-Id: <20231026115019.1377568-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780818697115186631 X-GMAIL-MSGID: 1780818697115186631 This patch leverage current MASK_GATHER_LOAD to support SLP MASK_LEN_GATHER_LOAD with condtional mask. Unconditional MASK_LEN_GATHER_LOAD (base, offset, scale, zero, -1) SLP is not included in this patch since it seems that we can't support it in the middle-end (due to PR44306). May be we should support GATHER_LOAD explictily in RISC-V backend to walk around this issue. I am gonna support GATHER_LOAD explictly work around in RISC-V backend. This patch also adds conditional gather load test since there is no conditional gather load test. Ok for trunk ? gcc/ChangeLog: * tree-vect-slp.cc (vect_get_operand_map): Add MASK_LEN_GATHER_LOAD. (vect_build_slp_tree_1): Ditto. (vect_build_slp_tree_2): Ditto. gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-gather-6.c: New test. --- gcc/testsuite/gcc.dg/vect/vect-gather-6.c | 15 +++++++++++++++ gcc/tree-vect-slp.cc | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-gather-6.c diff --git a/gcc/testsuite/gcc.dg/vect/vect-gather-6.c b/gcc/testsuite/gcc.dg/vect/vect-gather-6.c new file mode 100644 index 00000000000..ff55f321854 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-gather-6.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +void +f (int *restrict y, int *restrict x, int *restrict indices, int *restrict cond, int n) +{ + for (int i = 0; i < n; ++i) + { + if (cond[i * 2]) + y[i * 2] = x[indices[i * 2]] + 1; + if (cond[i * 2 + 1]) + y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2; + } +} + +/* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect { target vect_gather_load_ifn } } } */ diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 5eb310eceaf..0c197b50054 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -564,6 +564,7 @@ vect_get_operand_map (const gimple *stmt, bool gather_scatter_p = false, return arg1_map; case IFN_MASK_GATHER_LOAD: + case IFN_MASK_LEN_GATHER_LOAD: return arg1_arg4_map; case IFN_MASK_STORE: @@ -1158,7 +1159,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, if (cfn == CFN_MASK_LOAD || cfn == CFN_GATHER_LOAD - || cfn == CFN_MASK_GATHER_LOAD) + || cfn == CFN_MASK_GATHER_LOAD + || cfn == CFN_MASK_LEN_GATHER_LOAD) ldst_p = true; else if (cfn == CFN_MASK_STORE) { @@ -1425,6 +1427,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, if (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)) && rhs_code != CFN_GATHER_LOAD && rhs_code != CFN_MASK_GATHER_LOAD + && rhs_code != CFN_MASK_LEN_GATHER_LOAD && !STMT_VINFO_GATHER_SCATTER_P (stmt_info) /* Not grouped loads are handled as externals for BB vectorization. For loop vectorization we can handle @@ -1927,7 +1930,8 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, if (gcall *stmt = dyn_cast (stmt_info->stmt)) gcc_assert (gimple_call_internal_p (stmt, IFN_MASK_LOAD) || gimple_call_internal_p (stmt, IFN_GATHER_LOAD) - || gimple_call_internal_p (stmt, IFN_MASK_GATHER_LOAD)); + || gimple_call_internal_p (stmt, IFN_MASK_GATHER_LOAD) + || gimple_call_internal_p (stmt, IFN_MASK_LEN_GATHER_LOAD)); else if (STMT_VINFO_GATHER_SCATTER_P (stmt_info)) gcc_assert (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info))); else