From patchwork Wed Aug 9 11:02:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 133159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2714189vqr; Wed, 9 Aug 2023 04:02:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkFq8G6tA3M+Q4NMmITm7ep1elSY/PrsPG5gGNqDcoGaWqXCdSYq6jCIGfjBUBmt8EgnUx X-Received: by 2002:a05:6402:708:b0:523:3609:d3ca with SMTP id w8-20020a056402070800b005233609d3camr1948530edx.20.1691578965198; Wed, 09 Aug 2023 04:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691578965; cv=none; d=google.com; s=arc-20160816; b=mF7oVbKJmOZE8B6+27DX3+DT7AL95ZWlXCfZRnV0YMeo4hfhDKA5q6RJBhn3GhM/rg qIx996AwY9BBgxb3GN0WOieVm/8JmUkXhvzDd8kKimaLDH2UooghKTbl0OO1LKI8cSV/ IKKg1Z+4WoakTswoDD+/BtBvBc5ShCo9CEyfEBQ+oahqhYWnogIwSktcsFsa9NHgie9k EoL4fEjZFy9aRqgtKDLnJh3Ydqgvw4X2EQN7smKrX+zE1MRMP4hl1HDi4Q8qTxLOZ9eJ CYJNbrZoHKADjAwcrkUT0XW/6BIiYuMJtLHZCr2uXbQUhjskx7JDOGyS2HHP93f3vzML b/fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=276dYMI9mNSr4Ll4CM0CX09XYQBkNd05pTdwKgXH/sI=; fh=etb9MYHN7HLF/sff76ICVdPeKiI8ZsjoOL2bcdG0aog=; b=SnGKGd9yEPAt9t0Eedu4CpiBgwuBeMHLV9OhmPNWYhZ9gBWZi9uBhwS8TWMhRr2nPF 35Fzld0OJBWjLgMf2mNpeGXgNPmt0ZU7MPQJEOsU7FBOp/8xzXY6XxAwL1TkcXvlr6NQ /LiLuUtfrvNSpSvep7UremaUs/OjSHmIfAfEdArkj9EF1068tjOdFsOHHJcsv1a3iT1q ncWLef3GlHpyo6pB87XQtqJtRODx9dOYGhqLA+DQBaWzjQHo8NgvteQ6jVL1VDbayo4S V8jW/hZ2NpoiJ4BoOrdL+zUa9aSKurbu1iu9XUIC0jQ9jiYCL1Py1ANJ6elODUWJV33o Mh/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Blx6RU69; 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 u11-20020a05640207cb00b00522d86e9357si8499351edy.228.2023.08.09.04.02.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 04:02:45 -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=Blx6RU69; 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 2966438582B0 for ; Wed, 9 Aug 2023 11:02:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2966438582B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691578964; bh=276dYMI9mNSr4Ll4CM0CX09XYQBkNd05pTdwKgXH/sI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Blx6RU69LwBPjdhUhZ1LSuLzdfQTuEeSYp2fGDhkvRjU9vSorRbujjhCdfUqrB3wZ NGod2R5M7anSPPg3bwk5WedQZ/xdNMgOglwNrWBi678Tc8WFGJg047G6eIG404npez 0dvd6hQSNMJ/c7BoHPYxWyQbgg6B3353oq5Q7CgY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 46C5F3858D33 for ; Wed, 9 Aug 2023 11:02:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46C5F3858D33 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6181E21866 for ; Wed, 9 Aug 2023 11:02:00 +0000 (UTC) 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 5504C2C143 for ; Wed, 9 Aug 2023 11:02:00 +0000 (UTC) Date: Wed, 9 Aug 2023 11:02:00 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove insert location argument from vectorizable_live_operation User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 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 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230809110244.2966438582B0@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773749104949868211 X-GMAIL-MSGID: 1773749104949868211 The insert location argument isn't actually used but we compute that ourselves. There's a single spot, namely when asking for the loop mask via vect_get_loop_mask that the passed argument is used but that looks like an oversight. The following fixes that and adjusts vectorizable_live_operation and can_vectorize_live_stmts to no longer take a stmt iterator argument. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vectorizer.h (vectorizable_live_operation): Remove gimple_stmt_iterator * argument. * tree-vect-loop.cc (vectorizable_live_operation): Likewise. Adjust plumbing around vect_get_loop_mask. (vect_analyze_loop_operations): Adjust. * tree-vect-slp.cc (vect_slp_analyze_node_operations_1): Likewise. (vect_bb_slp_mark_live_stmts): Likewise. (vect_schedule_slp_node): Likewise. * tree-vect-stmts.cc (can_vectorize_live_stmts): Likewise. Remove gimple_stmt_iterator * argument. (vect_transform_stmt): Adjust. --- gcc/tree-vect-loop.cc | 12 ++++++------ gcc/tree-vect-slp.cc | 8 +++----- gcc/tree-vect-stmts.cc | 14 ++++++-------- gcc/tree-vectorizer.h | 3 +-- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index c2241ed0eb4..1cd6bb43194 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -2061,8 +2061,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) if (ok && STMT_VINFO_LIVE_P (stmt_info) && !PURE_SLP_STMT (stmt_info)) - ok = vectorizable_live_operation (loop_vinfo, - stmt_info, NULL, NULL, NULL, + ok = vectorizable_live_operation (loop_vinfo, stmt_info, NULL, NULL, -1, false, &cost_vec); if (!ok) @@ -10190,9 +10189,7 @@ vectorizable_induction (loop_vec_info loop_vinfo, it can be supported. */ bool -vectorizable_live_operation (vec_info *vinfo, - stmt_vec_info stmt_info, - gimple_stmt_iterator *gsi, +vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, slp_tree slp_node, slp_instance slp_node_instance, int slp_index, bool vec_stmt_p, stmt_vector_for_cost *cost_vec) @@ -10398,9 +10395,12 @@ vectorizable_live_operation (vec_info *vinfo, the loop mask for the final iteration. */ gcc_assert (ncopies == 1 && !slp_node); tree scalar_type = TREE_TYPE (STMT_VINFO_VECTYPE (stmt_info)); - tree mask = vect_get_loop_mask (loop_vinfo, gsi, + gimple_seq tem = NULL; + gimple_stmt_iterator gsi = gsi_last (tem); + tree mask = vect_get_loop_mask (loop_vinfo, &gsi, &LOOP_VINFO_MASKS (loop_vinfo), 1, vectype, 0); + gimple_seq_add_seq (&stmts, tem); tree scalar_res = gimple_build (&stmts, CFN_EXTRACT_LAST, scalar_type, mask, vec_lhs_phi); diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 6cfcda202e9..18119c09965 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -6014,8 +6014,7 @@ vect_slp_analyze_node_operations_1 (vec_info *vinfo, slp_tree node, FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, slp_stmt_info) { if (STMT_VINFO_LIVE_P (slp_stmt_info) - && !vectorizable_live_operation (vinfo, - slp_stmt_info, NULL, node, + && !vectorizable_live_operation (vinfo, slp_stmt_info, node, node_instance, i, false, cost_vec)) return false; @@ -6332,7 +6331,7 @@ vect_bb_slp_mark_live_stmts (bb_vec_info bb_vinfo, slp_tree node, { STMT_VINFO_LIVE_P (stmt_info) = true; if (vectorizable_live_operation (bb_vinfo, stmt_info, - NULL, node, instance, i, + node, instance, i, false, cost_vec)) /* ??? So we know we can vectorize the live stmt from one SLP node. If we cannot do so from all @@ -9049,8 +9048,7 @@ vect_schedule_slp_node (vec_info *vinfo, FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, slp_stmt_info) if (STMT_VINFO_LIVE_P (slp_stmt_info)) { - done = vectorizable_live_operation (vinfo, - slp_stmt_info, &si, node, + done = vectorizable_live_operation (vinfo, slp_stmt_info, node, instance, i, true, NULL); gcc_assert (done); } diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 76b1c83f41e..398fbe945e5 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -12011,11 +12011,10 @@ vectorizable_comparison (vec_info *vinfo, /* If SLP_NODE is nonnull, return true if vectorizable_live_operation can handle all live statements in the node. Otherwise return true if STMT_INFO is not live or if vectorizable_live_operation can handle it. - GSI and VEC_STMT_P are as for vectorizable_live_operation. */ + VEC_STMT_P is as for vectorizable_live_operation. */ static bool -can_vectorize_live_stmts (vec_info *vinfo, - stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, +can_vectorize_live_stmts (vec_info *vinfo, stmt_vec_info stmt_info, slp_tree slp_node, slp_instance slp_node_instance, bool vec_stmt_p, stmt_vector_for_cost *cost_vec) @@ -12027,15 +12026,14 @@ can_vectorize_live_stmts (vec_info *vinfo, FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (slp_node), i, slp_stmt_info) { if (STMT_VINFO_LIVE_P (slp_stmt_info) - && !vectorizable_live_operation (vinfo, - slp_stmt_info, gsi, slp_node, + && !vectorizable_live_operation (vinfo, slp_stmt_info, slp_node, slp_node_instance, i, vec_stmt_p, cost_vec)) return false; } } else if (STMT_VINFO_LIVE_P (stmt_info) - && !vectorizable_live_operation (vinfo, stmt_info, gsi, + && !vectorizable_live_operation (vinfo, stmt_info, slp_node, slp_node_instance, -1, vec_stmt_p, cost_vec)) return false; @@ -12270,7 +12268,7 @@ vect_analyze_stmt (vec_info *vinfo, && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type && STMT_VINFO_TYPE (stmt_info) != lc_phi_info_type && !can_vectorize_live_stmts (as_a (vinfo), - stmt_info, NULL, node, node_instance, + stmt_info, node, node_instance, false, cost_vec)) return opt_result::failure_at (stmt_info->stmt, "not vectorized:" @@ -12428,7 +12426,7 @@ vect_transform_stmt (vec_info *vinfo, { /* Handle stmts whose DEF is used outside the loop-nest that is being vectorized. */ - done = can_vectorize_live_stmts (vinfo, stmt_info, gsi, slp_node, + done = can_vectorize_live_stmts (vinfo, stmt_info, slp_node, slp_node_instance, true, NULL); gcc_assert (done); } diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 50458825ab9..e93f3892eb0 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -2364,8 +2364,7 @@ extern opt_result vect_analyze_loop_form (class loop *, vect_loop_form_info *); extern loop_vec_info vect_create_loop_vinfo (class loop *, vec_info_shared *, const vect_loop_form_info *, loop_vec_info = nullptr); -extern bool vectorizable_live_operation (vec_info *, - stmt_vec_info, gimple_stmt_iterator *, +extern bool vectorizable_live_operation (vec_info *, stmt_vec_info, slp_tree, slp_instance, int, bool, stmt_vector_for_cost *); extern bool vectorizable_reduction (loop_vec_info, stmt_vec_info,