From patchwork Tue Aug 8 05:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 132507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1893187vqr; Mon, 7 Aug 2023 22:26:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4FAmaPc+XmtrNR6aE4u8Fb+WeiyQ9WdAzXkq3xy0YU1nxZ+prLiaZftsOduj6PQaZlPV3 X-Received: by 2002:a17:907:75c9:b0:98e:26ae:9b07 with SMTP id jl9-20020a17090775c900b0098e26ae9b07mr8642209ejc.35.1691472367410; Mon, 07 Aug 2023 22:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691472367; cv=none; d=google.com; s=arc-20160816; b=PqvNaiQ64+PmHhnTJx0ORCuUuSfEsAmDnlaNhOByMOUZCfm/+mf/GXo5GW6k28kLDv T9YNR0za9zxKMZVTlbc4rWLBP7f8xKoLNuqchJOKDGs/tHFM2HmVXLLaE/jyqwIXXpjo RzyAiaArcFKaeUcXV3szXnOjp9J25gYv8V4ajJnX1j2G5BI/EUC+1hjlYzf3NM3Zsqaq LGkuaQljE0yoJCn1KZyxR7xvEGghz8+sU1vv6PrXnvmynRIUmN/ICkls3G7OXgjUW9wP IuYIvZCmPIKT4WVncXkH80394wO0MXZVMUTBAylr3bxO84afn7RpAXK6E5i2yA+d8+De V50g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=S6rur9mu0SvAkzlELWo66nCFllXIgJu2nrPJNINk0gs=; fh=m5jp0pdNlPEXs5loJZlB7PTIZjh+8jRjnDPOljuLfXA=; b=F+txsR4X+yxZeac5Rrj8qGlpDMLEBdVSxtZ+2n6xqREec8jPKXdq2zhUVay0FsHFB5 GuqKmcIxxhXuXEEnvXyq+Tk+gKsDUELrGfWP0sN/172DAFRv8m1bO3vYaB7yIiFsl/CG nXmP+xzx4/x5X+rYaYasqU5r6wZTNVtrHj6AefrwDhEq4s+mB8/BWtzm6zidvM9/7oVU A+fgDMgHnYOKtQSaoOu6UM/E2gFWwJsFJOIkgHD03Qsl1B1jL8OjV/5tYAHPSiF3wuB/ Z5iWHdMHPML6cqiCWrvhcWFYZZeqt0q5LMk+VtfKV2CGVjksx395SSAC9MjpQLY0xxlL n0RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wOlmWmiX; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 q18-20020a1709066ad200b00993166137f5si6784771ejs.140.2023.08.07.22.26.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 22:26:07 -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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wOlmWmiX; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E0B793858017 for ; Tue, 8 Aug 2023 05:26:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0B793858017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691472365; bh=S6rur9mu0SvAkzlELWo66nCFllXIgJu2nrPJNINk0gs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=wOlmWmiXB/MysC+EHPo6kUGCspBVqMRo2HfofjkqpIQSk5HKSpFti2X/iOKR1xszW cWM/X8ypOYKTuwnUHcj8t54P9Gcj7fEx8hprLxURM2PhPWL8Jc8EC7+eaTqaebareB 9Z8L7knzK1un+TYF49+yrwqJnyAUUF1LzomCnKjc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id C9FCC3858D33 for ; Tue, 8 Aug 2023 05:25:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9FCC3858D33 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="434572720" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="434572720" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 22:25:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="731241210" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="731241210" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga002.jf.intel.com with ESMTP; 07 Aug 2023 22:25:10 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 625D01005613; Tue, 8 Aug 2023 13:25:09 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, jeffreyalaw@gmail.com, pan2.li@intel.com, yanzhang.wang@intel.com, kito.cheng@gmail.com, Kito Cheng Subject: [PATCH v2] RISC-V: Refactor RVV frm_mode attr for rounding mode intrinsic Date: Tue, 8 Aug 2023 13:25:08 +0800 Message-Id: <20230808052508.968486-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230806033612.1078855-1-pan2.li@intel.com> References: <20230806033612.1078855-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773449280374170517 X-GMAIL-MSGID: 1773637328906051277 From: Pan Li The frm_mode attr has some assumptions for each define insn as below. 1. The define insn has at least 9 operands. 2. The operands[9] must be frm reg. 3. The operands[9] must be const int. Actually, the frm operand can be operands[8], operands[9] or operands[10], and not all the define insn has frm operands. This patch would like to refactor frm and eliminate the above assumptions, as well as unblock the underlying rounding mode intrinsic API support. After refactor, the default frm will be none, and the selected insn type will be dyn. For the floating point which honors the frm, we will set the frm_mode attr explicitly in define_insn. Signed-off-by: Pan Li Co-Authored-by: Kito Cheng gcc/ChangeLog: * config/riscv/riscv-protos.h (get_frm_mode): Remove operand assumptions. * config/riscv/riscv-v.cc (get_frm_mode): New function. * config/riscv/riscv-vector-builtins.cc (function_expander::use_ternop_insn): * config/riscv/vector.md: Set frm_mode attr explicitly. gcc/ChangeLog: * config/riscv/riscv-protos.h (enum floating_point_rounding_mode): Add NONE, DYN_EXIT and DYN_CALL. (get_frm_mode): New declaration. * config/riscv/riscv-v.cc (get_frm_mode): New function to get frm mode. * config/riscv/riscv-vector-builtins.cc (function_expander::use_ternop_insn): Take care of frm reg. * config/riscv/riscv.cc (riscv_static_frm_mode_p): Migrate to FRM_XXX. (riscv_emit_frm_mode_set): Ditto. (riscv_emit_mode_set): Ditto. (riscv_frm_adjust_mode_after_call): Ditto. (riscv_frm_mode_needed): Ditto. (riscv_frm_mode_after): Ditto. (riscv_mode_entry): Ditto. (riscv_mode_exit): Ditto. * config/riscv/riscv.h (NUM_MODES_FOR_MODE_SWITCHING): Ditto. * config/riscv/vector.md (rne,rtz,rdn,rup,rmm,dyn,dyn_exit,dyn_call,none): Removed (symbol_ref): * config/riscv/vector.md: Set frm_mode attr explicitly. --- gcc/config/riscv/riscv-protos.h | 4 + gcc/config/riscv/riscv-v.cc | 29 ++++ gcc/config/riscv/riscv-vector-builtins.cc | 22 ++- gcc/config/riscv/riscv.cc | 46 +++--- gcc/config/riscv/riscv.h | 2 +- gcc/config/riscv/vector.md | 172 ++++++++++++++-------- 6 files changed, 186 insertions(+), 89 deletions(-) diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 324991e2619..f45653848de 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -344,8 +344,12 @@ enum floating_point_rounding_mode FRM_DYN = 7, /* Aka 0b111. */ FRM_STATIC_MIN = FRM_RNE, FRM_STATIC_MAX = FRM_RMM, + FRM_DYN_EXIT = 8, + FRM_DYN_CALL = 9, + FRM_NONE = 10, }; +enum floating_point_rounding_mode get_frm_mode (rtx); opt_machine_mode vectorize_related_mode (machine_mode, scalar_mode, poly_uint64); unsigned int autovectorize_vector_modes (vec *, bool); diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index 278452b9e05..9ab6ae17d33 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -112,6 +112,7 @@ public: { m_has_fp_rounding_mode_p = true; m_fp_rounding_mode = mode; + gcc_assert (mode <= FRM_DYN); } void add_output_operand (rtx x, machine_mode mode) @@ -1513,6 +1514,34 @@ expand_const_vector (rtx target, rtx src) gcc_unreachable (); } +/* Get the frm mode with given CONST_INT rtx, the default mode is + FRM_DYN. */ +enum floating_point_rounding_mode +get_frm_mode (rtx operand) +{ + gcc_assert (CONST_INT_P (operand)); + + switch (INTVAL (operand)) + { + case FRM_RNE: + return FRM_RNE; + case FRM_RTZ: + return FRM_RTZ; + case FRM_RDN: + return FRM_RDN; + case FRM_RUP: + return FRM_RUP; + case FRM_RMM: + return FRM_RMM; + case FRM_DYN: + return FRM_DYN; + default: + return FRM_DYN; + } + + gcc_unreachable (); +} + /* Expand a pre-RA RVV data move from SRC to DEST. It expands move for RVV fractional vector modes. */ bool diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index 528dca7ae85..abab06c00ed 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -3730,17 +3730,29 @@ function_expander::use_ternop_insn (bool vd_accum_p, insn_code icode) } for (int argno = arg_offset; argno < call_expr_nargs (exp); argno++) - add_input_operand (argno); + { + if (base->has_rounding_mode_operand_p () + && argno == call_expr_nargs (exp) - 2) + { + /* Since the rounding mode argument position is not consistent with + the instruction pattern, we need to skip rounding mode argument + here. */ + continue; + } + add_input_operand (argno); + } add_input_operand (Pmode, get_tail_policy_for_pred (pred)); add_input_operand (Pmode, get_mask_policy_for_pred (pred)); add_input_operand (Pmode, get_avl_type_rtx (avl_type::NONVLMAX)); - /* TODO: Currently, we don't support intrinsic that is modeling rounding mode. - We add default rounding mode for the intrinsics that didn't model rounding - mode yet. */ + if (base->has_rounding_mode_operand_p ()) + add_input_operand (call_expr_nargs (exp) - 2); + + /* The RVV floating-point only support dynamic rounding mode in the + FRM register. */ if (opno != insn_data[icode].n_generator_args) - add_input_operand (Pmode, const0_rtx); + add_input_operand (Pmode, gen_int_mode (riscv_vector::FRM_DYN, Pmode)); return generate_insn (icode); } diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 7728cd34569..c6ffd74905a 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -7947,11 +7947,11 @@ riscv_static_frm_mode_p (int mode) { switch (mode) { - case FRM_MODE_RDN: - case FRM_MODE_RUP: - case FRM_MODE_RTZ: - case FRM_MODE_RMM: - case FRM_MODE_RNE: + case riscv_vector::FRM_RDN: + case riscv_vector::FRM_RUP: + case riscv_vector::FRM_RTZ: + case riscv_vector::FRM_RMM: + case riscv_vector::FRM_RNE: return true; default: return false; @@ -7967,28 +7967,24 @@ riscv_emit_frm_mode_set (int mode, int prev_mode) { rtx backup_reg = DYNAMIC_FRM_RTL (cfun); - if (prev_mode == FRM_MODE_DYN_CALL) + if (prev_mode == riscv_vector::FRM_DYN_CALL) emit_insn (gen_frrmsi (backup_reg)); /* Backup frm when DYN_CALL. */ if (mode != prev_mode) { - /* TODO: By design, FRM_MODE_xxx used by mode switch which is - different from the FRM value like FRM_RTZ defined in - riscv-protos.h. When mode switching we actually need a conversion - function to convert the mode of mode switching to the actual - FRM value like FRM_RTZ. For now, the value between the mode of - mode swith and the FRM value in riscv-protos.h take the same value, - and then we leverage this assumption when emit. */ rtx frm = gen_int_mode (mode, SImode); - if (mode == FRM_MODE_DYN_CALL && prev_mode != FRM_MODE_DYN) + if (mode == riscv_vector::FRM_DYN_CALL + && prev_mode != riscv_vector::FRM_DYN) /* No need to emit when prev mode is DYN already. */ emit_insn (gen_fsrmsi_restore_volatile (backup_reg)); - else if (mode == FRM_MODE_DYN_EXIT && STATIC_FRM_P (cfun) - && prev_mode != FRM_MODE_DYN && prev_mode != FRM_MODE_DYN_CALL) + else if (mode == riscv_vector::FRM_DYN_EXIT && STATIC_FRM_P (cfun) + && prev_mode != riscv_vector::FRM_DYN + && prev_mode != riscv_vector::FRM_DYN_CALL) /* No need to emit when prev mode is DYN or DYN_CALL already. */ emit_insn (gen_fsrmsi_restore_volatile (backup_reg)); - else if (mode == FRM_MODE_DYN && prev_mode != FRM_MODE_DYN_CALL) + else if (mode == riscv_vector::FRM_DYN + && prev_mode != riscv_vector::FRM_DYN_CALL) /* Restore frm value from backup when switch to DYN mode. */ emit_insn (gen_fsrmsi_restore (backup_reg)); else if (riscv_static_frm_mode_p (mode)) @@ -8017,7 +8013,7 @@ riscv_emit_mode_set (int entity, int mode, int prev_mode, } } -/* Adjust the FRM_MODE_NONE insn after a call to FRM_MODE_DYN for the +/* Adjust the FRM_NONE insn after a call to FRM_DYN for the underlying emit. */ static int @@ -8026,7 +8022,7 @@ riscv_frm_adjust_mode_after_call (rtx_insn *cur_insn, int mode) rtx_insn *insn = prev_nonnote_nondebug_insn_bb (cur_insn); if (insn && CALL_P (insn)) - return FRM_MODE_DYN; + return riscv_vector::FRM_DYN; return mode; } @@ -8077,12 +8073,12 @@ riscv_frm_mode_needed (rtx_insn *cur_insn, int code) if (!insn) riscv_frm_emit_after_bb_end (cur_insn); - return FRM_MODE_DYN_CALL; + return riscv_vector::FRM_DYN_CALL; } - int mode = code >= 0 ? get_attr_frm_mode (cur_insn) : FRM_MODE_NONE; + int mode = code >= 0 ? get_attr_frm_mode (cur_insn) : riscv_vector::FRM_NONE; - if (mode == FRM_MODE_NONE) + if (mode == riscv_vector::FRM_NONE) /* After meet a call, we need to backup the frm because it may be updated during the call. Here, for each insn, we will check if the previous insn is a call or not. When previous insn is call, @@ -8190,7 +8186,7 @@ riscv_frm_mode_after (rtx_insn *insn, int mode) return mode; if (frm_unknown_dynamic_p (insn)) - return FRM_MODE_DYN; + return riscv_vector::FRM_DYN; if (recog_memoized (insn) < 0) return mode; @@ -8232,7 +8228,7 @@ riscv_mode_entry (int entity) /* According to RVV 1.0 spec, all vector floating-point operations use the dynamic rounding mode in the frm register. Likewise in other similar places. */ - return FRM_MODE_DYN; + return riscv_vector::FRM_DYN; } default: gcc_unreachable (); @@ -8250,7 +8246,7 @@ riscv_mode_exit (int entity) case RISCV_VXRM: return VXRM_MODE_NONE; case RISCV_FRM: - return FRM_MODE_DYN_EXIT; + return riscv_vector::FRM_DYN_EXIT; default: gcc_unreachable (); } diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 643e7ea7330..746101ea933 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -1120,6 +1120,6 @@ extern void riscv_remove_unneeded_save_restore_calls (void); /* Mode switching (Lazy code motion) for RVV rounding mode instructions. */ #define OPTIMIZE_MODE_SWITCHING(ENTITY) (TARGET_VECTOR) -#define NUM_MODES_FOR_MODE_SWITCHING {VXRM_MODE_NONE, FRM_MODE_NONE} +#define NUM_MODES_FOR_MODE_SWITCHING {VXRM_MODE_NONE, riscv_vector::FRM_NONE} #endif /* ! GCC_RISCV_H */ diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 750b2de8df9..6cdda609a5a 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -865,28 +865,10 @@ (define_attr "vxrm_mode" "rnu,rne,rdn,rod,none" (const_string "none"))) ;; Defines rounding mode of an floating-point operation. -(define_attr "frm_mode" "rne,rtz,rdn,rup,rmm,dyn,dyn_exit,dyn_call,none" +(define_attr "frm_mode" "" (cond [(eq_attr "type" "vfalu,vfwalu,vfmul,vfdiv,vfwmul") - (cond - [(match_test "INTVAL (operands[9]) == riscv_vector::FRM_RNE") - (const_string "rne") - - (match_test "INTVAL (operands[9]) == riscv_vector::FRM_RTZ") - (const_string "rtz") - - (match_test "INTVAL (operands[9]) == riscv_vector::FRM_RDN") - (const_string "rdn") - - (match_test "INTVAL (operands[9]) == riscv_vector::FRM_RUP") - (const_string "rup") - - (match_test "INTVAL (operands[9]) == riscv_vector::FRM_RMM") - (const_string "rmm") - - (match_test "INTVAL (operands[9]) == riscv_vector::FRM_DYN") - (const_string "dyn")] - (const_string "none"))] - (const_string "none"))) + (symbol_ref "riscv_vector::FRM_DYN")] + (symbol_ref "riscv_vector::FRM_NONE"))) ;; ----------------------------------------------------------------- ;; ---- Miscellaneous Operations @@ -6147,7 +6129,9 @@ (define_insn "@pred_" "TARGET_VECTOR" "vf.vv\t%0,%3,%4%p1" [(set_attr "type" "") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_" [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr") @@ -6190,7 +6174,9 @@ (define_insn "@pred__scalar" "TARGET_VECTOR" "vf.vf\t%0,%3,%4%p1" [(set_attr "type" "") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred__scalar" [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr") @@ -6234,7 +6220,9 @@ (define_insn "@pred__scalar" "TARGET_VECTOR" "vf.vf\t%0,%3,%4%p1" [(set_attr "type" "") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred__reverse_scalar" [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr") @@ -6257,7 +6245,9 @@ (define_insn "@pred__reverse_scalar" "TARGET_VECTOR" "vfr.vf\t%0,%3,%4%p1" [(set_attr "type" "") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_" [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr") @@ -6408,7 +6398,9 @@ (define_insn "*pred_" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "*pred_" [(set (match_operand:VF 0 "register_operand" "=vd, ?&vd, vr, ?&vr") @@ -6441,7 +6433,9 @@ (define_insn "*pred_" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn_and_rewrite "*pred_mul_" [(set (match_operand:VF 0 "register_operand" "=&vr, ?&vr") @@ -6478,7 +6472,9 @@ (define_insn_and_rewrite "*pred_mul_" operands[5] = operands[4] = operands[0]; } [(set_attr "type" "vfmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))]) (define_expand "@pred_mul__scalar" [(set (match_operand:VF 0 "register_operand") @@ -6535,7 +6531,9 @@ (define_insn "*pred__scalar" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "*pred__scalar" [(set (match_operand:VF 0 "register_operand" "=vd, ?&vd, vr, ?&vr") @@ -6569,7 +6567,9 @@ (define_insn "*pred__scalar" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn_and_rewrite "*pred_mul__scalar" [(set (match_operand:VF 0 "register_operand" "=&vr, ?&vr") @@ -6606,7 +6606,9 @@ (define_insn_and_rewrite "*pred_mul__scalar" operands[5] = operands[4] = operands[0]; } [(set_attr "type" "vfmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))]) (define_expand "@pred_mul_neg_" [(set (match_operand:VF 0 "register_operand") @@ -6668,7 +6670,9 @@ (define_insn "*pred_" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "*pred_" [(set (match_operand:VF 0 "register_operand" "=vd, ?&vd, vr, ?&vr") @@ -6702,7 +6706,9 @@ (define_insn "*pred_" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn_and_rewrite "*pred_mul_neg_" [(set (match_operand:VF 0 "register_operand" "=&vr, ?&vr") @@ -6740,7 +6746,9 @@ (define_insn_and_rewrite "*pred_mul_neg_" operands[5] = operands[4] = operands[0]; } [(set_attr "type" "vfmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))]) (define_expand "@pred_mul_neg__scalar" [(set (match_operand:VF 0 "register_operand") @@ -6799,7 +6807,9 @@ (define_insn "*pred__scalar" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "*pred__scalar" [(set (match_operand:VF 0 "register_operand" "=vd, ?&vd, vr, ?&vr") @@ -6834,7 +6844,9 @@ (define_insn "*pred__scalar" (set_attr "vl_op_idx" "5") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[8])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn_and_rewrite "*pred_mul_neg__scalar" [(set (match_operand:VF 0 "register_operand" "=&vr, ?&vr") @@ -6872,7 +6884,9 @@ (define_insn_and_rewrite "*pred_mul_neg__scalar" operands[5] = operands[4] = operands[0]; } [(set_attr "type" "vfmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))]) ;; ------------------------------------------------------------------------------- ;; ---- Predicated floating-point unary operations @@ -6908,7 +6922,9 @@ (define_insn "@pred_" (set_attr "vl_op_idx" "4") (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])")) (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])")) - (set (attr "avl_type") (symbol_ref "INTVAL (operands[7])"))]) + (set (attr "avl_type") (symbol_ref "INTVAL (operands[7])")) + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) (define_insn "@pred_" [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr") @@ -7002,7 +7018,9 @@ (define_insn "@pred_dual_widen_" "TARGET_VECTOR" "vfw.vv\t%0,%3,%4%p1" [(set_attr "type" "vf") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_dual_widen__scalar" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr") @@ -7027,7 +7045,9 @@ (define_insn "@pred_dual_widen__scalar" "TARGET_VECTOR" "vfw.vf\t%0,%3,%4%p1" [(set_attr "type" "vf") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_single_widen_add" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr") @@ -7050,7 +7070,9 @@ (define_insn "@pred_single_widen_add" "TARGET_VECTOR" "vfwadd.wv\t%0,%3,%4%p1" [(set_attr "type" "vfwalu") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_single_widen_sub" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr") @@ -7073,7 +7095,9 @@ (define_insn "@pred_single_widen_sub" "TARGET_VECTOR" "vfwsub.wv\t%0,%3,%4%p1" [(set_attr "type" "vfwalu") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_single_widen__scalar" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr") @@ -7097,7 +7121,9 @@ (define_insn "@pred_single_widen__scalar" "TARGET_VECTOR" "vfw.wf\t%0,%3,%4%p1" [(set_attr "type" "vf") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) ;; ------------------------------------------------------------------------------- ;; ---- Predicated widen floating-point ternary operations @@ -7130,7 +7156,9 @@ (define_insn "@pred_widen_mul_" "TARGET_VECTOR" "vfw.vv\t%0,%3,%4%p1" [(set_attr "type" "vfwmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_widen_mul__scalar" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr") @@ -7157,7 +7185,9 @@ (define_insn "@pred_widen_mul__scalar" "TARGET_VECTOR" "vfw.vf\t%0,%3,%4%p1" [(set_attr "type" "vfwmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_widen_mul_neg_" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr") @@ -7184,7 +7214,9 @@ (define_insn "@pred_widen_mul_neg_" "TARGET_VECTOR" "vfw.vv\t%0,%3,%4%p1" [(set_attr "type" "vfwmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) (define_insn "@pred_widen_mul_neg__scalar" [(set (match_operand:VWEXTF 0 "register_operand" "=&vr") @@ -7212,7 +7244,9 @@ (define_insn "@pred_widen_mul_neg__scalar" "TARGET_VECTOR" "vfw.vf\t%0,%3,%4%p1" [(set_attr "type" "vfwmuladd") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))]) ;; ------------------------------------------------------------------------------- ;; ---- Predicated floating-point comparison operations @@ -7522,7 +7556,9 @@ (define_insn "@pred_fcvt_x_f" "TARGET_VECTOR" "vfcvt.x.f.v\t%0,%3%p1" [(set_attr "type" "vfcvtftoi") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) (define_insn "@pred_" [(set (match_operand: 0 "register_operand" "=vd, vd, vr, vr") @@ -7562,7 +7598,9 @@ (define_insn "@pred_" "TARGET_VECTOR" "vfcvt.f.x.v\t%0,%3%p1" [(set_attr "type" "vfcvtitof") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) ;; ------------------------------------------------------------------------------- ;; ---- Predicated floating-point widen conversions @@ -7590,7 +7628,9 @@ (define_insn "@pred_widen_fcvt_x_f" "TARGET_VECTOR" "vfwcvt.x.f.v\t%0,%3%p1" [(set_attr "type" "vfwcvtftoi") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) (define_insn "@pred_widen_" [(set (match_operand:VWCONVERTI 0 "register_operand" "=&vr, &vr") @@ -7675,7 +7715,9 @@ (define_insn "@pred_narrow_fcvt_x_f" "TARGET_VECTOR" "vfncvt.x.f.w\t%0,%3%p1" [(set_attr "type" "vfncvtftoi") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) (define_insn "@pred_narrow_" [(set (match_operand: 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr") @@ -7715,7 +7757,9 @@ (define_insn "@pred_narrow_" "TARGET_VECTOR" "vfncvt.f.x.w\t%0,%3%p1" [(set_attr "type" "vfncvtitof") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) (define_insn "@pred_trunc" [(set (match_operand: 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr") @@ -7736,7 +7780,9 @@ (define_insn "@pred_trunc" "TARGET_VECTOR" "vfncvt.f.f.w\t%0,%3%p1" [(set_attr "type" "vfncvtftof") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) (define_insn "@pred_rod_trunc" [(set (match_operand: 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr") @@ -8016,7 +8062,9 @@ (define_insn "@pred_reduc_plus" "TARGET_VECTOR" "vfredsum.vs\t%0,%3,%4%p1" [(set_attr "type" "vfred") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) ;; Float Ordered Reduction Sum for SF (define_insn "@pred_reduc_plus" @@ -8042,7 +8090,9 @@ (define_insn "@pred_reduc_plus" "TARGET_VECTOR" "vfredsum.vs\t%0,%3,%4%p1" [(set_attr "type" "vfred") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) ;; Float Ordered Reduction Sum for DF (define_insn "@pred_reduc_plus" @@ -8068,7 +8118,9 @@ (define_insn "@pred_reduc_plus" "TARGET_VECTOR" "vfredsum.vs\t%0,%3,%4%p1" [(set_attr "type" "vfred") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) ;; Float Widen Reduction for HF, aka SF = HF op SF (define_insn "@pred_widen_reduc_plus" @@ -8090,7 +8142,9 @@ (define_insn "@pred_widen_reduc_plus" "TARGET_VECTOR" "vfwredsum.vs\t%0,%3,%4%p1" [(set_attr "type" "vfwred") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) ;; Float Widen Reduction for SF, aka DF = SF * DF (define_insn "@pred_widen_reduc_plus" @@ -8112,7 +8166,9 @@ (define_insn "@pred_widen_reduc_plus" "TARGET_VECTOR" "vfwredsum.vs\t%0,%3,%4%p1" [(set_attr "type" "vfwred") - (set_attr "mode" "")]) + (set_attr "mode" "") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))]) ;; ------------------------------------------------------------------------------- ;; ---- Predicated permutation operations