From patchwork Mon Sep 18 11:08:25 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: 141358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2571316vqi; Mon, 18 Sep 2023 04:09:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaJmArWrwl/QBX2PYBu9Yy1y+wNTvsdcEbDwCE+W3zXYMHIAzOLh2a54nu2AucRr3hIh9a X-Received: by 2002:a05:6402:2913:b0:530:9d8e:216b with SMTP id ee19-20020a056402291300b005309d8e216bmr6512387edb.30.1695035356072; Mon, 18 Sep 2023 04:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695035356; cv=none; d=google.com; s=arc-20160816; b=YGonQ0wuiGr2yrbm4bHHUUXDmepeSjleC4Qdxv9v0+s+DfEyq4TmDjr5wCP1aXRt6n Nr23lemmvFNflCmcJetrs+GJBdCxHJd00h78g0tKqYS3ldzYjDTdkk9YddVDy9dF04s/ SeUwXBfeCk7K1wktws9NPl5wgnku4r7ksKBT2HTbtAk9UKe78WufT2gjvwg7UZYgkbRb rUUs+GGU9Fv3n69zIgj6pMbO6zHckgfuSq+vxVXewQUQ8RDBDE3SBCazUsHJElufV8Ki RW+wJ8h9NPAIQivPHLk3T5DOfv1q9qge79B0ReaqDdX3916xrH/M/DCTpSp896tGr+5k llOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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:dmarc-filter:delivered-to; bh=oM9bLW6cCiT0z3u240n+dEmt/s71F9gV/Dm+g7kf4AY=; fh=12MRPJmZ1mgDpHqWoogMKqnaGRGM2b7lcuJroqfjJiw=; b=x5PgV2v7bN5dUnbBb0FnjIjwF9WI5zMd9ucKStfe4C8s5z5ou/QNEoRzVCgTNgjEo7 E2REeOdioEPiew1d39bsO/xr+tyjA8m5k5XZxePWmYWqdf15tlBgCXYvfc7XxQHgsUyw 2qYZYZfsjRRMx8tG9uWzbwEYbkW1/VRk1CmCa/3hP9gN8zHqi9/03PldD1JS7XrZi33f omfvEA1ssqNfaeEHCpTz3J4au92WWfxc2amLvIp8spd8iJP8PIrkO86yQ/zun3LcMN5M dXWbdv/WjyIHFjP5gfsfrVrjSn4SZsX7tC76+WyhkyQcmKbSFaV7d+/qO/WB4hSsAMfo DtWw== 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 d23-20020a50fb17000000b005312de19435si725397edq.10.2023.09.18.04.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 04:09:16 -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 9493C3857731 for ; Mon, 18 Sep 2023 11:08:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) by sourceware.org (Postfix) with ESMTPS id 504E83858C66 for ; Mon, 18 Sep 2023 11:08:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 504E83858C66 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: bizesmtp63t1695035308t1291yf9 Received: from rios-cad121.hadoop.rioslab.org ( [58.60.1.9]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 18 Sep 2023 19:08:26 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: +ynUkgUhZJl/8HyhyS+uikWv4m/235iLM14l9ZdnL3/eANp318fvvcN5Cs254 8Z0bq0Z7o5q+9A7cvDrIRV8e5LSqlhVp61P6bQDVqLdW0X+JR7WNZYr5Hi5qfriRpe+DP6g au6vbADpK0wQdTLY8KMw4e3h00CiZqPF1WEF9c2DwK6iwOu50RKiq6CZD0mH9IYN/43L81V VpK5Y/0mxl5C5vW+j6PaNctvaNQQe28iN1mswtUK4Xk6pEPS1qOnoWo8F1Ef2PRBt+9qQmr vY7I2ANJ11GZUHOeHPIGByOjy7Mz0jVDlbu9KRBZc3fEXzU7kxnuMg+ruZI7FPaUP4lPHV4 o297w4G2d2zL0Uy4KE70kTscOnhvwMKBamJf3NpmMx2ngnNRLDR/Kx4FAjNERWteianZjWg X-QQ-GoodBg: 2 X-BIZMAIL-ID: 17043097667414549247 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [Committed] RISC-V: Fix VSETVL PASS fusion bug Date: Mon, 18 Sep 2023 19:08:25 +0800 Message-Id: <20230918110825.3134855-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.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777373393216358684 X-GMAIL-MSGID: 1777373393216358684 There is an obvious fusion bug that is exposed by more VLS patterns support. After more VLS modes support, it cause following FAILs: FAIL: gcc.target/riscv/rvv/autovec/reduc/reduc_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/reduc/reduc_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/reduc/reduc_run-2.c execution test FAIL: gcc.target/riscv/rvv/autovec/reduc/reduc_run-2.c execution test Demand 1: SEW = 64, LMUL = 1, RATIO = 64, demand SEW, demand GE_SEW. Demand 2: SEW = 64, LMUL = 2, RATIO = 32, demand SEW, demand GE_SEW, demand RATIO. Before this patch: merge demand: SEW = 64, LMUL = 1, RATIO = 32, demand SEW, demand LMUL, demand GE_SEW. It's obvious incorrect of merge LMUL which should be new LMUL = (demand 2 RATIO * greatest SEW) = M2 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (vlmul_for_greatest_sew_second_ratio): New function. * config/riscv/riscv-vsetvl.def (DEF_SEW_LMUL_FUSE_RULE): Fix bug. --- gcc/config/riscv/riscv-vsetvl.cc | 8 ++++++++ gcc/config/riscv/riscv-vsetvl.def | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 5f031c18df5..df980b6770e 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -1308,6 +1308,14 @@ vlmul_for_first_sew_second_ratio (const vector_insn_info &info1, return calculate_vlmul (info1.get_sew (), info2.get_ratio ()); } +static vlmul_type +vlmul_for_greatest_sew_second_ratio (const vector_insn_info &info1, + const vector_insn_info &info2) +{ + return calculate_vlmul (MAX (info1.get_sew (), info2.get_sew ()), + info2.get_ratio ()); +} + static unsigned ratio_for_second_sew_first_vlmul (const vector_insn_info &info1, const vector_insn_info &info2) diff --git a/gcc/config/riscv/riscv-vsetvl.def b/gcc/config/riscv/riscv-vsetvl.def index 7289c01efcf..709cc4ee0df 100644 --- a/gcc/config/riscv/riscv-vsetvl.def +++ b/gcc/config/riscv/riscv-vsetvl.def @@ -329,8 +329,8 @@ DEF_SEW_LMUL_FUSE_RULE (/*SEW*/ DEMAND_TRUE, /*LMUL*/ DEMAND_FALSE, /*NEW_DEMAND_SEW*/ true, /*NEW_DEMAND_LMUL*/ false, /*NEW_DEMAND_RATIO*/ true, - /*NEW_DEMAND_GE_SEW*/ true, greatest_sew, first_vlmul, - second_ratio) + /*NEW_DEMAND_GE_SEW*/ true, greatest_sew, + vlmul_for_greatest_sew_second_ratio, second_ratio) DEF_SEW_LMUL_FUSE_RULE (/*SEW*/ DEMAND_TRUE, /*LMUL*/ DEMAND_FALSE, /*RATIO*/ DEMAND_ANY, /*GE_SEW*/ DEMAND_TRUE, /*SEW*/ DEMAND_FALSE, /*LMUL*/ DEMAND_TRUE,