From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2119) id 233603857713; Mon, 18 Sep 2023 18:28:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 233603857713 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695061697; bh=nf6+pgrySxD8w+UYR8Yb/RrvLvr+LDXVZOJ2RVrRm6U=; h=From:To:Subject:Date:From; b=H1Gf9AbxwRNzFNSxtgHsECyvBgx9MSgue2HmxNZIvgizTrIdrFVEUTIkQu4VfEUJm yjiBol0NczVWNQexmqHfhoAUkCc/uR3z2bUe486SaD6dN8jHzf4X2P3twli3l8m+yk wrA89D4pmgEewX3PWTB04Lq6+rkRNhggCLalrcKA= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jeff Law To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Fix VSETVL PASS fusion bug X-Act-Checkin: gcc X-Git-Author: Juzhe-Zhong X-Git-Refname: refs/vendors/riscv/heads/gcc-13-with-riscv-opts X-Git-Oldrev: 4a60e111a29f798eb4a0b478e375927447ee9b8a X-Git-Newrev: ebc06ff84738455d1c9da3d5f82f91bd9203c5b5 Message-Id: <20230918182817.233603857713@sourceware.org> Date: Mon, 18 Sep 2023 18:28:17 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ebc06ff84738455d1c9da3d5f82f91bd9203c5b5 commit ebc06ff84738455d1c9da3d5f82f91bd9203c5b5 Author: Juzhe-Zhong Date: Mon Sep 18 19:08:25 2023 +0800 RISC-V: Fix VSETVL PASS fusion bug 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. (cherry picked from commit 8fbc0871da26fac1668ba939f4492876794734ac) Diff: --- 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,