From patchwork Mon Aug 28 11:40:05 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: 137026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp3267282vqm; Mon, 28 Aug 2023 04:40:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECkSOClp/eZaq02JwP6MhrA5UbtV1SEyVHwuEDtBXDCWECtaIiBFz0XFc6saih1+AZrfwx X-Received: by 2002:a17:906:1444:b0:99b:c845:791d with SMTP id q4-20020a170906144400b0099bc845791dmr17843376ejc.76.1693222845456; Mon, 28 Aug 2023 04:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693222845; cv=none; d=google.com; s=arc-20160816; b=Cyue9WQ8nw3W48eZm+zbYt3RKTSkcHT+MYpGZu4AiWzfMaGr0ZyM5dwZ2IjQteeI8D I/9Vg6TfaM23CaCu9KcnMlKJ03JDgrbVyXsgRqOngZMVJR7OB4p+X3v4TbPk//RcgZa/ zgPpfiJHTU9UXB6TzibwhEScMpWyXpUiFhg54AMLOI8g7Q4hUhoFvqIGN8aSCaLiJP8R WZ6arcKu3PE0ZnL8D603d7Yb73RfzpZnN7Sk2k4lT3eiLgvTJRB6PqR800kWwYpbxPbh 161WSRcEg5TpUvv+b0hzGJKCEAGwoVLG3ufkIEs1t7nOykha1r12Yf7T8eIH7KNcOxnr 9XfQ== 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=okW2rS/WLJ01ZYYyeYLkXfM3v7O991Mgb0R5/qTl9AE=; fh=arl273cIQBNH1P6XLxHQvF0scgitfd773vOV+bwQx3o=; b=J4kzSfv2z8EGfNnCGZwcbmaQPKmiBPFdF+Uad3knAcQZB/HoOR5ybUF5T24XEeGlmh oF8OsylFGWxw8n5+d+DW6szHTRxskmAppXoKA3F+HocuVJQBz9AaJUPMQbG5PVvL2S4d 2p9W9pcdb9AtgF7h8fh/gfR9AA16xHO2pTMJCTCdXI/4ml/fjWycjLpap539goB6gJbs nj2z6etaLIeaO7Toaq2Kw1QeZO1X86iDQXtDM6qviptvCUzoPwLAYr5EVXXd7PG93nUe /Nva6aLWNxpXnZWGYl5Ne5n/HhtZKYqzSOSdpU/jK59pn9nrRyzavBaMihb4vqAI/qMd yPWg== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id g16-20020a1709065d1000b0099bd8bf3e32si5049103ejt.233.2023.08.28.04.40.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 04:40: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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 545703858004 for ; Mon, 28 Aug 2023 11:40:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by sourceware.org (Postfix) with ESMTPS id 105D33858D28 for ; Mon, 28 Aug 2023 11:40:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 105D33858D28 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: bizesmtp89t1693222807tfysps9n Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 28 Aug 2023 19:40:06 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: Fc2LLDWeHZ+/4S5yWYITvfpwyxDRHW7pooOHBpOD2kJKUtjjOQXRzBa7DB625 W9eBx0sHj8FjnItwo0mdV2i6DIQwOhT+wOCAiDcwciKjcXFIwMrFRoEpneTio4CCHSC4wAd m7yEfn5HtlQdBUI6nblfCqXLlC+MtlrwZaihX5S8d+SBtL3BXaosuSBjS92TiTfMPfgT3mv 7LF35Lo22TiXi/sRBGEEtcVkLjGk6ZcGPu0TeoFq1hQ5iZF74yyb4IBfDZVyvyCNMcyoNJd /+9SggWxRN5inN/89udbBIuoRKeCONEWMKtMBq20Pvnm1QcXBLPazaknf0jEIt3sjHUsj/x Xr32tlxdNg1g7nR3c2U8x9cuQhMLhzQuIbCRumW9XhTUeLOC7Xm+PY2H73YLD0uzMnDlNZR /wQh1AUxJ9VvVNnGWaQYHQ== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 2269029993880409300 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Subject: [PATCH] RISC-V: Fix uninitialized probability for GIMPLE IR tests Date: Mon, 28 Aug 2023 19:40:05 +0800 Message-Id: <20230828114005.2100796-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_H3, RCVD_IN_MSPIKE_WL, 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: , 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: 1775472837930239062 X-GMAIL-MSGID: 1775472837930239062 This patch fix unitialized probability in GIMPLE IR code tests: FAIL: gcc.dg/vect/slp-reduc-10a.c (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10a.c (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10a.c -flto -ffat-lto-objects (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10a.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10b.c (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10b.c (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10b.c -flto -ffat-lto-objects (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10b.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10c.c (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10c.c (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10c.c -flto -ffat-lto-objects (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10c.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10d.c (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10d.c (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10d.c -flto -ffat-lto-objects (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10d.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10e.c (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10e.c (test for excess errors) FAIL: gcc.dg/vect/slp-reduc-10e.c -flto -ffat-lto-objects (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/slp-reduc-10e.c -flto -ffat-lto-objects (test for excess errors) FAIL: gcc.dg/vect/vect-cond-arith-2.c (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/vect-cond-arith-2.c (test for excess errors) FAIL: gcc.dg/vect/vect-cond-arith-2.c -flto -ffat-lto-objects (internal compiler error: in compute_probabilities, at config/riscv/riscv-vsetvl.cc:4358) FAIL: gcc.dg/vect/vect-cond-arith-2.c -flto -ffat-lto-objects (test for excess errors) gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::earliest_fusion): Skip never probability. (pass_vsetvl::compute_probabilities): Fix unitialized probability. --- gcc/config/riscv/riscv-vsetvl.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 48e89fe2c03..f7ae6c16bee 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -3272,6 +3272,10 @@ pass_vsetvl::earliest_fusion (void) if (expr.empty_p ()) continue; edge eg = INDEX_EDGE (m_vector_manager->vector_edge_list, ed); + /* If it is the edge that we never reach, skip its possible PRE + fusion conservatively. */ + if (eg->probability == profile_probability::never ()) + break; if (eg->src == ENTRY_BLOCK_PTR_FOR_FN (cfun) || eg->dest == EXIT_BLOCK_PTR_FOR_FN (cfun)) break; @@ -4359,7 +4363,14 @@ pass_vsetvl::compute_probabilities (void) FOR_EACH_EDGE (e, ei, cfg_bb->succs) { auto &new_prob = get_block_info (e->dest).probability; - if (!new_prob.initialized_p ()) + /* Normally, the edge probability should be initialized. + However, some special testing code which is written in + GIMPLE IR style force the edge probility uninitialized, + we conservatively set it as never so that it will not + affect PRE (Phase 3 && Phse 4). */ + if (!e->probability.initialized_p ()) + new_prob = profile_probability::never (); + else if (!new_prob.initialized_p ()) new_prob = curr_prob * e->probability; else if (new_prob == profile_probability::always ()) continue;