From: Fei Gao <gaofei@eswincomputing.com>
To: gcc-patches@gcc.gnu.org
Cc: kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com,
Fei Gao <gaofei@eswincomputing.com>
Subject: [PATCH 1/4] [RISC-V]add hook to control Zicond based ifcvt opt
Date: Mon, 30 Oct 2023 07:25:20 +0000 [thread overview]
Message-ID: <20231030072523.26818-2-gaofei@eswincomputing.com> (raw)
In-Reply-To: <20231030072523.26818-1-gaofei@eswincomputing.com>
TARGET_HAVE_COND_ZERO is added to control ifcvt optimization
for targets with RISC-V Zicond like insns.
Co-authored-by: Xiao Zeng<zengxiao@eswincomputing.com>
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_have_cond_zero): Implement TARGET_HAVE_COND_ZERO
(TARGET_HAVE_COND_ZERO): define RISC-V hook
* doc/tm.texi: add TARGET_HAVE_COND_ZERO
* doc/tm.texi.in: add TARGET_HAVE_COND_ZERO
* target.def: define TARGET_HAVE_COND_ZERO
---
gcc/config/riscv/riscv.cc | 10 ++++++++++
gcc/doc/tm.texi | 4 ++++
gcc/doc/tm.texi.in | 2 ++
gcc/target.def | 7 +++++++
4 files changed, 23 insertions(+)
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index ca9a2ca81d5..16a91713ba5 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9597,6 +9597,13 @@ riscv_vectorize_create_costs (vec_info *vinfo, bool costing_for_scalar)
return new vector_costs (vinfo, costing_for_scalar);
}
+/* Implement TARGET_HAVE_COND_ZERO. */
+bool
+riscv_have_cond_zero (void)
+{
+ return TARGET_ZICOND_LIKE;
+}
+
/* Implement TARGET_PREFERRED_ELSE_VALUE. */
static tree
@@ -9884,6 +9891,9 @@ riscv_preferred_else_value (unsigned ifn, tree vectype, unsigned int nops,
#undef TARGET_DWARF_POLY_INDETERMINATE_VALUE
#define TARGET_DWARF_POLY_INDETERMINATE_VALUE riscv_dwarf_poly_indeterminate_value
+#undef TARGET_HAVE_COND_ZERO
+#define TARGET_HAVE_COND_ZERO riscv_have_cond_zero
+
#undef TARGET_ZERO_CALL_USED_REGS
#define TARGET_ZERO_CALL_USED_REGS riscv_zero_call_used_regs
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index f7ac806ff15..fe4f59d445e 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -12080,6 +12080,10 @@ This target hook is required only when the target has several different
modes and they have different conditional execution capability, such as ARM.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_HAVE_COND_ZERO (void)
+This target hook returns true if the target supports conditional zero.
+@end deftypefn
+
@deftypefn {Target Hook} rtx TARGET_GEN_CCMP_FIRST (rtx_insn **@var{prep_seq}, rtx_insn **@var{gen_seq}, rtx_code @var{code}, tree @var{op0}, tree @var{op1})
This function prepares to emit a comparison insn for the first compare in a
sequence of conditional comparisions. It returns an appropriate comparison
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 141027e0bb4..12aadd75a13 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -7832,6 +7832,8 @@ lists.
@hook TARGET_HAVE_CONDITIONAL_EXECUTION
+@hook TARGET_HAVE_COND_ZERO
+
@hook TARGET_GEN_CCMP_FIRST
@hook TARGET_GEN_CCMP_NEXT
diff --git a/gcc/target.def b/gcc/target.def
index 42622177ef9..f977edc3430 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2726,6 +2726,13 @@ modes and they have different conditional execution capability, such as ARM.",
bool, (void),
default_have_conditional_execution)
+/* Return true if the target supports conditional zero. */
+DEFHOOK
+(have_cond_zero,
+ "This target hook returns true if the target supports conditional zero.",
+ bool, (void),
+ hook_bool_void_false)
+
DEFHOOK
(gen_ccmp_first,
"This function prepares to emit a comparison insn for the first compare in a\n\
--
2.17.1
next prev parent reply other threads:[~2023-10-30 7:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 7:25 [PATCH 0/4] add support for conditional zero operation Fei Gao
2023-10-30 7:25 ` Fei Gao [this message]
2023-10-30 15:12 ` [PATCH 1/4] [RISC-V]add hook to control Zicond based ifcvt opt Jeff Law
2023-10-30 7:25 ` [PATCH 2/4] [ifcvt] if convert x=c ? y+z : y by RISC-V Zicond like insns Fei Gao
2023-10-30 16:36 ` Jeff Law
2023-10-31 2:53 ` Fei Gao
2023-10-30 18:41 ` Jeff Law
2023-10-30 19:16 ` Jeff Law
2023-10-31 3:35 ` Fei Gao
2023-11-20 6:46 ` Jeff Law
2023-11-28 2:46 ` Fei Gao
2023-11-28 5:05 ` Jeff Law
2023-11-20 6:59 ` Jeff Law
2023-11-28 2:57 ` Fei Gao
2023-11-29 4:46 ` Jeff Law
2023-10-30 7:25 ` [PATCH 3/4] [ifcvt] if convert x=c ? y op z " Fei Gao
2023-11-20 7:02 ` Jeff Law
2023-10-30 7:25 ` [PATCH 4/4] [ifcvt] if convert x=c ? y&z " Fei Gao
2023-10-30 18:46 ` Jeff Law
2023-11-20 7:10 ` Jeff Law
2023-11-28 3:04 ` Fei Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231030072523.26818-2-gaofei@eswincomputing.com \
--to=gaofei@eswincomputing.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=kito.cheng@gmail.com \
--cc=palmer@dabbelt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).