From patchwork Mon Aug 28 09:53: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: 137017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp3219283vqm; Mon, 28 Aug 2023 02:54:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGTPLXzyXRURbKrGNI67DVI5iSRPzh47sraBnG7/lqNz0TILh3+U+mWBm1UIAebAGzSdMt X-Received: by 2002:aa7:d058:0:b0:522:4c7a:d5a9 with SMTP id n24-20020aa7d058000000b005224c7ad5a9mr20218855edo.3.1693216457576; Mon, 28 Aug 2023 02:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693216457; cv=none; d=google.com; s=arc-20160816; b=ItQWEW3PqBcAamDsJkhKbsicGL6k5KL3FuhpHRtf0EV2C+U8I79UERyypcbhg/sGog x+5d8D3+U1rPRYkQyFF7AoYOtep4PvydCmLmQCdrbq/bgdfLqI5DfT0aJlyJs6yAE7D4 3rfCBC7b52x1qNxzajzPtTRvpxX4SSujNcAUTSivo5MvzcpzVuZbKYe5cb5EnnAWhRcX Zk+eq1y3er/cEntTMuouSvq4Qnkbp/OntTnw+pjXXWUMnmfGNRpWHjOCJpytyCmOn01A AJnKcZ06nMkig9T7uo++KSYpDAvytgDaAvQWkln43DqWt1efOHMM2QUGlwRK/A9H0UO/ 7q5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:to :from:dmarc-filter:delivered-to; bh=P0bNv55N7wwoH0Xb0VAup6jZziytBgva4pha2dYxSnQ=; fh=arl273cIQBNH1P6XLxHQvF0scgitfd773vOV+bwQx3o=; b=TD+NUCwHXBh7varCTM0Rq0XIK7uHGAtAJ2yhOar8YdMJOC9scCz411AqaIjWAQpejA LWD0WyJvI+F0ICbcNU+3wzgOneMzM3abSXxRwEWkFw7ss3HcLi6YIPU5dIM1puubsbmo 432S5/poe6gyJvEJxcxfZOiAS27dXZ/Z3N5vz/59anUOaR7rzNXfGOoTG9FMBx4SIRjB MWjgVNOodrKGH+LKf1ZbaYx1HihqgLZouP6z6cFCxcp6TppZCmP3AqTvbi2nQKw96XLU fJbj0o6vExU3Id8ebiNE8KMTrVAAUNB+JDHphFcTeYpfXpMaCaWvE599qS8lhYdJV5u2 JqYw== ARC-Authentication-Results: i=1; mx.google.com; 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 m16-20020a50ef10000000b00523bc9ccc6dsi4311326eds.26.2023.08.28.02.54.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 02:54:17 -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; 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 554F0385843E for ; Mon, 28 Aug 2023 09:54:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by sourceware.org (Postfix) with ESMTPS id 7D6DF3858D28 for ; Mon, 28 Aug 2023 09:53:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7D6DF3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp63t1693216401t79syys8 Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 28 Aug 2023 17:53:20 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: C46Rb8GPIEdn3r9Suq/96IGBf8c1SAoLzByfizxLnzLjuergTUbyzZTUQIp3f yxGFW8B/rtJmOaQCJbiIR+0cJ88zB4I2plXnK6E788vTBczHYOL0QxxtAvf7mSJiHDcQhpY u/RaolSbDTA/IvGSVn4ZUEuiODY9BNFPrOSf/+27sbdzMcMFsIZt/lI5NZfYSyB93pslYRm EMDn9grf648R1HFGm6TqChEmO3Jwrsp48byMwrTZONUb6oRsBQxpyICUczO/vnYPxZJeq5b p0afuygbsTlx6Xg2amcmFqFh9hm5ccoPgvGQtgkehrOLMnDw56q4BB762PQv7KjRiGWoaFj CjlnIeVkgC8LdjgLYya5Pz2foc72JEZemwvYLKB6h4Bw/rVnS1H7HvJBjb+qkN+0ZmCk8Ju hs9QW/0eINJ/OUBO4ZnO+g== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 222091067041776821 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Subject: [PATCH V2] RISC-V: Disable user vsetvl fusion into EMPTY or DIRTY (Polluted EMPTY) block Date: Mon, 28 Aug 2023 17:53:19 +0800 Message-Id: <20230828095319.2083553-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=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, TXREP, T_SPF_HELO_TEMPERROR 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: , Cc: kito.cheng@sifive.com, kito.cheng@gmail.com, Juzhe-Zhong Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775466140028209593 X-GMAIL-MSGID: 1775466140028209593 This patch is fixing these bunch of ICE in "vect" testsuite: FAIL: gcc.dg/vect/no-scevccp-outer-2.c (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/no-scevccp-outer-2.c (test for excess errors) FAIL: gcc.dg/vect/pr109025.c (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/pr109025.c (test for excess errors) FAIL: gcc.dg/vect/pr109025.c -flto -ffat-lto-objects (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/pr109025.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/pr42604.c (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/pr42604.c (test for excess errors) FAIL: gcc.dg/vect/pr42604.c -flto -ffat-lto-objects (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/pr42604.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/vect-double-reduc-3.c (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/vect-double-reduc-3.c (test for excess errors) FAIL: gcc.dg/vect/vect-double-reduc-3.c -flto -ffat-lto-objects (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/vect-double-reduc-3.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/vect-double-reduc-7.c (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/vect-double-reduc-7.c (test for excess errors) FAIL: gcc.dg/vect/vect-double-reduc-7.c -flto -ffat-lto-objects (internal compiler error: in anticipatable_occurrence_p, at config/riscv/riscv-vsetvl.cc:314) FAIL: gcc.dg/vect/vect-double-reduc-7.c -flto -ffat-lto-objects (test for excess errors) gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::earliest_fusion): Fix bug. --- gcc/config/riscv/riscv-vsetvl.cc | 38 ++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 682f795c8e1..48e89fe2c03 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -3285,12 +3285,46 @@ pass_vsetvl::earliest_fusion (void) gcc_assert (!(eg->flags & EDGE_ABNORMAL)); vector_insn_info new_info = vector_insn_info (); profile_probability prob = src_block_info.probability; + /* We don't fuse user vsetvl into EMPTY or + DIRTY (EMPTY but polluted) block for these + following reasons: + + - The user vsetvl instruction is configured as + no side effects that the previous passes + (GSCE, Loop-invariant, ..., etc) + should be able to do a good job on optimization + of user explicit vsetvls so we don't need to + PRE optimization (The user vsetvls should be + on the optimal local already before this pass) + again for user vsetvls in VSETVL PASS here + (Phase 3 && Phase 4). + + - Allowing user vsetvls be optimized in PRE + optimization here (Phase 3 && Phase 4) will + complicate the codes so much so we prefer user + vsetvls be optimized in post-optimization + (Phase 5 && Phase 6). */ + if (vsetvl_insn_p (expr.get_insn ()->rtl ())) + { + if (src_block_info.reaching_out.empty_p ()) + continue; + else if (src_block_info.reaching_out.dirty_p () + && !src_block_info.reaching_out.compatible_p (expr)) + { + new_info.set_empty (); + /* Update probability as uninitialized status so that + we won't try to fuse any demand info into such EMPTY + block any more. */ + prob = profile_probability::uninitialized (); + update_block_info (eg->src->index, prob, new_info); + continue; + } + } if (src_block_info.reaching_out.empty_p ()) { if (src_block_info.probability - == profile_probability::uninitialized () - || vsetvl_insn_p (expr.get_insn ()->rtl ())) + == profile_probability::uninitialized ()) continue; new_info = expr.global_merge (expr, eg->src->index); new_info.set_dirty ();