From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2093) id 1E8B738582AB; Fri, 23 Dec 2022 05:42:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E8B738582AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671774164; bh=GWgC4b2QTLYz8CasrKA+k02OjKOx3s67Bme3gnvpHpc=; h=From:To:Subject:Date:From; b=lNPZIOdHg5qACcccipWEiuyS8XA/uBmYN9NS5RlyNlrX3SlwJFZ7f8IicEqSB8V+s nwwgd9elfVagzbQMmZHqcBBsXvfXXbnGhbLJcSf6BwyziPmEId584cL5nq9fwYqsv7 aRyLBUGzc7W8a6z9DtuxMB+LMebzdmP/sZJjAsYQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kito Cheng To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4866] RISC-V: Remove side effects of vsetvl pattern in RTL. X-Act-Checkin: gcc X-Git-Author: Ju-Zhe Zhong X-Git-Refname: refs/heads/master X-Git-Oldrev: 37fd10fd3eb42ea4487d93521a267ba08a9f8575 X-Git-Newrev: b47b33c799bd4874a4c81fb71708ff1c3dd150ff Message-Id: <20221223054244.1E8B738582AB@sourceware.org> Date: Fri, 23 Dec 2022 05:42:44 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b47b33c799bd4874a4c81fb71708ff1c3dd150ff commit r13-4866-gb47b33c799bd4874a4c81fb71708ff1c3dd150ff Author: Ju-Zhe Zhong Date: Tue Dec 20 22:56:49 2022 +0800 RISC-V: Remove side effects of vsetvl pattern in RTL. gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc: Change it to no side effects. * config/riscv/vector.md (@vsetvl_no_side_effects): New pattern. Diff: --- gcc/config/riscv/riscv-vector-builtins-bases.cc | 2 +- gcc/config/riscv/vector.md | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.cc b/gcc/config/riscv/riscv-vector-builtins-bases.cc index 75879dea25a..c1193dbbfb5 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -75,7 +75,7 @@ public: /* MU. */ e.add_input_operand (Pmode, gen_int_mode (0, Pmode)); - return e.generate_insn (code_for_vsetvl (Pmode)); + return e.generate_insn (code_for_vsetvl_no_side_effects (Pmode)); } }; diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 52ca6b3d25c..fd8e285a7e6 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -585,6 +585,32 @@ [(set_attr "type" "vsetvl") (set_attr "mode" "")]) +;; It's emit by vsetvl/vsetvlmax intrinsics with no side effects. +;; Since we have many optmization passes from "expand" to "reload_completed", +;; such pattern can allow us gain benefits of these optimizations. +(define_insn_and_split "@vsetvl_no_side_effects" + [(set (match_operand:P 0 "register_operand" "=r") + (unspec:P [(match_operand:P 1 "csr_operand" "rK") + (match_operand 2 "const_int_operand" "i") + (match_operand 3 "const_int_operand" "i") + (match_operand 4 "const_int_operand" "i") + (match_operand 5 "const_int_operand" "i")] UNSPEC_VSETVL))] + "TARGET_VECTOR" + "#" + "&& epilogue_completed" + [(parallel + [(set (match_dup 0) + (unspec:P [(match_dup 1) (match_dup 2) (match_dup 3) + (match_dup 4) (match_dup 5)] UNSPEC_VSETVL)) + (set (reg:SI VL_REGNUM) + (unspec:SI [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPEC_VSETVL)) + (set (reg:SI VTYPE_REGNUM) + (unspec:SI [(match_dup 2) (match_dup 3) (match_dup 4) + (match_dup 5)] UNSPEC_VSETVL))])] + "" + [(set_attr "type" "vsetvl") + (set_attr "mode" "SI")]) + ;; RVV machine description matching format ;; (define_insn "" ;; [(set (match_operand:MODE 0)