From patchwork Mon Jul 3 02:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 115172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp248474vqx; Sun, 2 Jul 2023 19:58:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHT/RO6uZNpl5c+SGe4mvyClqImIq/fIjes8teRyvrTnF4b8JqSXybVLIzdMBueMncJIYGf X-Received: by 2002:adf:e747:0:b0:314:2f5b:2ce with SMTP id c7-20020adfe747000000b003142f5b02cemr3613111wrn.12.1688353138987; Sun, 02 Jul 2023 19:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688353138; cv=none; d=google.com; s=arc-20160816; b=Mn2tsCRPMqdK7mwVG8+C5+w0fCTBJHoxcz9Jv9IaGbQHBzhHkNBAwyOb2pPMd6zjg7 QIYZEMFjylwFhnEcbucYHNZYw+cudXGn5ikdZgT5O5CvHPwcQpAAnvs1PrQYKsQYKUXj tuDQZmusfCKCjPPJS76cFWW0LwGAwF80Fu9Bq00Z8+v4IyB7exwH0TsXN7CTGbbX3tSu XL33DzgGjkRUPQ642/gDRlRy8y/jF8T9XgR8Md3zHXGZebAEsxm4r/EiLWb7ASEuVFam /hqHQsY9iuXyVxSCghuW3UyZN4aCvmp6gcH9uZSwtU6/AB9oxAOCurCqfrnmHRHq9Pv6 lIXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:in-reply-to:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=hltAxlBZC3ffaxqiyTZd31RpYTza0aEH/AQqrJf9QJ0=; fh=x1Iqopjbig094LZrUnMNEDYGMcEsJ01u8XwORcg+Pss=; b=c/MLaYD0QVoql56hT78f+DCfHDyYvtDrHBGB1Q1xvC0IIcCkxLRwkN3fHVxoKYrk1V Bv8F+IeRESOk3+GeJwyUWno1rKyB8OpOfe/hnzORRSFCsKik0LvJVqeh95oEVv5PJg4/ xtZcaXXwgq2kmBxrFBRf+5xb7RLgsqds/W/1nGry2iX/WUX4/SubkW5TpEaU1P6kgnhN 4LpzXSQuZa91pO2Y+qjOTZkus9fuwznItEvMsEbZg89Vz/OxyxYC6XO9bZOc+xc4taCM +VvkJ7EIqXMgbMo3HObhXAVwR0WXWh02+vG59DXL74ZcdGll+DE8b8pfCP8GApZtnsiW JZRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=muzOCzsz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id pw6-20020a17090720a600b0099307a6635esi1772106ejb.701.2023.07.02.19.58.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 19:58:58 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=muzOCzsz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D91A3857704 for ; Mon, 3 Jul 2023 02:58:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D91A3857704 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688353136; bh=hltAxlBZC3ffaxqiyTZd31RpYTza0aEH/AQqrJf9QJ0=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=muzOCzszujfQzKUC/SiTxuYq6flB5dltdr4y8zTZPP37H2/njKcJ9ffJN3rYgse6y zo0HUe3HxGkMVn8SWKGuy/Bdlr+OJsrhaG5SFd0HdGMopLQDLu1rAr4otp3KiJORws 3IIAqNkZsezW6KS/3mi8HvxMjq5jLQcpQpgBJniI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 099973858D28 for ; Mon, 3 Jul 2023 02:58:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 099973858D28 Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3632vmNV016300; Mon, 3 Jul 2023 02:58:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rkp0r8053-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jul 2023 02:58:07 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3632w7l8016722; Mon, 3 Jul 2023 02:58:07 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rkp0r804r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jul 2023 02:58:07 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 362NMAYE026322; Mon, 3 Jul 2023 02:58:05 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma05fra.de.ibm.com (PPS) with ESMTPS id 3rjbs4rs14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jul 2023 02:58:04 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3632w2sY18809416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Jul 2023 02:58:02 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F6E420043; Mon, 3 Jul 2023 02:58:02 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3AA6120040; Mon, 3 Jul 2023 02:58:00 +0000 (GMT) Received: from [9.197.241.204] (unknown [9.197.241.204]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 3 Jul 2023 02:57:59 +0000 (GMT) Message-ID: <90665240-729b-b07e-61a9-eed0cbdff95a@linux.ibm.com> Date: Mon, 3 Jul 2023 10:57:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH 2/9 v2] vect: Adjust vectorizable_load costing on VMAT_GATHER_SCATTER && gs_info.decl Content-Language: en-US To: Richard Biener Cc: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com, segher@kernel.crashing.org, bergner@linux.ibm.com References: <9bad792a4bcef35fbd9906245bf3493672b340fe.1686573640.git.linkw@linux.ibm.com> In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6iaYLg84fVyM-nb-HqM1pfZV7x1DOtg3 X-Proofpoint-ORIG-GUID: kwVgAvUwjxthPFXZuwbMQhq_fzjMmD9O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-03_02,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307030022 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768551343692288197?= X-GMAIL-MSGID: =?utf-8?q?1770366581188816440?= Hi Richi, on 2023/6/30 19:11, Richard Biener wrote: > On Tue, Jun 13, 2023 at 4:03 AM Kewen Lin wrote: >> >> This patch adds one extra argument cost_vec to function >> vect_build_gather_load_calls, so that we can do costing >> next to the tranform in vect_build_gather_load_calls. >> For now, the implementation just follows the handlings in >> vect_model_load_cost, it isn't so good, so placing one >> FIXME for any further improvement. This patch should not >> cause any functional changes. >> >> gcc/ChangeLog: >> >> * tree-vect-stmts.cc (vect_build_gather_load_calls): Add the handlings >> on costing with one extra argument cost_vec. >> (vectorizable_load): Adjust the call to vect_build_gather_load_calls. >> (vect_model_load_cost): Assert it won't get VMAT_GATHER_SCATTER with >> gs_info.decl set any more. >> --- >> gcc/tree-vect-stmts.cc | 31 +++++++++++++++++++++++-------- >> 1 file changed, 23 insertions(+), 8 deletions(-) >> >> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc >> index 44514658be3..744cdf40e26 100644 >> --- a/gcc/tree-vect-stmts.cc >> +++ b/gcc/tree-vect-stmts.cc >> @@ -1135,6 +1135,8 @@ vect_model_load_cost (vec_info *vinfo, >> slp_tree slp_node, >> stmt_vector_for_cost *cost_vec) >> { >> + gcc_assert (memory_access_type != VMAT_GATHER_SCATTER || !gs_info->decl); >> + >> unsigned int inside_cost = 0, prologue_cost = 0; >> bool grouped_access_p = STMT_VINFO_GROUPED_ACCESS (stmt_info); >> >> @@ -2819,7 +2821,8 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info, >> gimple_stmt_iterator *gsi, >> gimple **vec_stmt, >> gather_scatter_info *gs_info, >> - tree mask) >> + tree mask, >> + stmt_vector_for_cost *cost_vec) >> { >> loop_vec_info loop_vinfo = dyn_cast (vinfo); >> class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); >> @@ -2831,6 +2834,23 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info, >> poly_uint64 gather_off_nunits >> = TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype); >> >> + /* FIXME: Keep the previous costing way in vect_model_load_cost by costing >> + N scalar loads, but it should be tweaked to use target specific costs >> + on related gather load calls. */ >> + if (!vec_stmt) > > going over the series now, I'm collecting comments but wanted to get > this one out here: > I'd rather see if (cost_vec) here, that 'vec_stmt' argument is quite > legacy (I think it can > be completely purged everywhere) > OK, updated with the below new version v2. I guessed you meant we would like to use cost_vec for checking costing or not and use vec_stmts in stmt_info to store the vectorized stmt. --- 2.31.1 diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index ec177dcad82..dd8f5421d4e 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -1136,6 +1136,8 @@ vect_model_load_cost (vec_info *vinfo, slp_tree slp_node, stmt_vector_for_cost *cost_vec) { + gcc_assert (memory_access_type != VMAT_GATHER_SCATTER || !gs_info->decl); + unsigned int inside_cost = 0, prologue_cost = 0; bool grouped_access_p = STMT_VINFO_GROUPED_ACCESS (stmt_info); @@ -2846,7 +2848,8 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, gimple **vec_stmt, gather_scatter_info *gs_info, - tree mask) + tree mask, + stmt_vector_for_cost *cost_vec) { loop_vec_info loop_vinfo = dyn_cast (vinfo); class loop *loop = LOOP_VINFO_LOOP (loop_vinfo); @@ -2858,6 +2861,23 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info, poly_uint64 gather_off_nunits = TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype); + /* FIXME: Keep the previous costing way in vect_model_load_cost by costing + N scalar loads, but it should be tweaked to use target specific costs + on related gather load calls. */ + if (cost_vec) + { + unsigned int assumed_nunits = vect_nunits_for_cost (vectype); + unsigned int inside_cost; + inside_cost = record_stmt_cost (cost_vec, ncopies * assumed_nunits, + scalar_load, stmt_info, 0, vect_body); + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "vect_model_load_cost: inside_cost = %d, " + "prologue_cost = 0 .\n", + inside_cost); + return; + } + tree arglist = TYPE_ARG_TYPES (TREE_TYPE (gs_info->decl)); tree rettype = TREE_TYPE (TREE_TYPE (gs_info->decl)); tree srctype = TREE_VALUE (arglist); arglist = TREE_CHAIN (arglist); @@ -9631,13 +9651,8 @@ vectorizable_load (vec_info *vinfo, if (memory_access_type == VMAT_GATHER_SCATTER && gs_info.decl) { - if (costing_p) - vect_model_load_cost (vinfo, stmt_info, ncopies, vf, memory_access_type, - alignment_support_scheme, misalignment, &gs_info, - slp_node, cost_vec); - else - vect_build_gather_load_calls (vinfo, stmt_info, gsi, vec_stmt, &gs_info, - mask); + vect_build_gather_load_calls (vinfo, stmt_info, gsi, vec_stmt, &gs_info, + mask, cost_vec); return true; }