* [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges
@ 2023-11-09 6:50 pan2.li
2023-11-09 6:53 ` juzhe.zhong
0 siblings, 1 reply; 3+ messages in thread
From: pan2.li @ 2023-11-09 6:50 UTC (permalink / raw)
To: gcc-patches; +Cc: juzhe.zhong, pan2.li, yanzhang.wang, kito.cheng
From: Pan Li <pan2.li@intel.com>
This patch would like to fine the frm insn emit when we
meet abnormal edge in the loop. Conceptually, we only need
to emit once when abnormal instead of every iteration in
the loop.
This patch would like to fix this defect and only perform
insert_insn_end_basic_block when at least one succ edge is
abnormal.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_frm_emit_after_bb_end): Only
perform once emit when at least one succ edge is abnormal.
Signed-off-by: Pan Li <pan2.li@intel.com>
---
gcc/config/riscv/riscv.cc | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 08ff05dcc3f..e25692b86fc 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9348,20 +9348,33 @@ static void
riscv_frm_emit_after_bb_end (rtx_insn *cur_insn)
{
edge eg;
+ bool abnormal_edge_p = false;
edge_iterator eg_iterator;
basic_block bb = BLOCK_FOR_INSN (cur_insn);
FOR_EACH_EDGE (eg, eg_iterator, bb->succs)
+ {
+ if (eg->flags & EDGE_ABNORMAL)
+ abnormal_edge_p = true;
+ else
+ {
+ start_sequence ();
+ emit_insn (gen_frrmsi (DYNAMIC_FRM_RTL (cfun)));
+ rtx_insn *backup_insn = get_insns ();
+ end_sequence ();
+
+ insert_insn_on_edge (backup_insn, eg);
+ }
+ }
+
+ if (abnormal_edge_p)
{
start_sequence ();
emit_insn (gen_frrmsi (DYNAMIC_FRM_RTL (cfun)));
rtx_insn *backup_insn = get_insns ();
end_sequence ();
- if (eg->flags & EDGE_ABNORMAL)
- insert_insn_end_basic_block (backup_insn, bb);
- else
- insert_insn_on_edge (backup_insn, eg);
+ insert_insn_end_basic_block (backup_insn, bb);
}
commit_edge_insertions ();
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges
2023-11-09 6:50 [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges pan2.li
@ 2023-11-09 6:53 ` juzhe.zhong
2023-11-09 12:34 ` Li, Pan2
0 siblings, 1 reply; 3+ messages in thread
From: juzhe.zhong @ 2023-11-09 6:53 UTC (permalink / raw)
To: pan2.li, gcc-patches; +Cc: pan2.li, yanzhang.wang, kito.cheng
[-- Attachment #1: Type: text/plain, Size: 2054 bytes --]
OK。
juzhe.zhong@rivai.ai
From: pan2.li
Date: 2023-11-09 14:50
To: gcc-patches
CC: juzhe.zhong; pan2.li; yanzhang.wang; kito.cheng
Subject: [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges
From: Pan Li <pan2.li@intel.com>
This patch would like to fine the frm insn emit when we
meet abnormal edge in the loop. Conceptually, we only need
to emit once when abnormal instead of every iteration in
the loop.
This patch would like to fix this defect and only perform
insert_insn_end_basic_block when at least one succ edge is
abnormal.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_frm_emit_after_bb_end): Only
perform once emit when at least one succ edge is abnormal.
Signed-off-by: Pan Li <pan2.li@intel.com>
---
gcc/config/riscv/riscv.cc | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 08ff05dcc3f..e25692b86fc 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9348,20 +9348,33 @@ static void
riscv_frm_emit_after_bb_end (rtx_insn *cur_insn)
{
edge eg;
+ bool abnormal_edge_p = false;
edge_iterator eg_iterator;
basic_block bb = BLOCK_FOR_INSN (cur_insn);
FOR_EACH_EDGE (eg, eg_iterator, bb->succs)
+ {
+ if (eg->flags & EDGE_ABNORMAL)
+ abnormal_edge_p = true;
+ else
+ {
+ start_sequence ();
+ emit_insn (gen_frrmsi (DYNAMIC_FRM_RTL (cfun)));
+ rtx_insn *backup_insn = get_insns ();
+ end_sequence ();
+
+ insert_insn_on_edge (backup_insn, eg);
+ }
+ }
+
+ if (abnormal_edge_p)
{
start_sequence ();
emit_insn (gen_frrmsi (DYNAMIC_FRM_RTL (cfun)));
rtx_insn *backup_insn = get_insns ();
end_sequence ();
- if (eg->flags & EDGE_ABNORMAL)
- insert_insn_end_basic_block (backup_insn, bb);
- else
- insert_insn_on_edge (backup_insn, eg);
+ insert_insn_end_basic_block (backup_insn, bb);
}
commit_edge_insertions ();
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges
2023-11-09 6:53 ` juzhe.zhong
@ 2023-11-09 12:34 ` Li, Pan2
0 siblings, 0 replies; 3+ messages in thread
From: Li, Pan2 @ 2023-11-09 12:34 UTC (permalink / raw)
To: juzhe.zhong, gcc-patches; +Cc: Wang, Yanzhang, kito.cheng
[-- Attachment #1: Type: text/plain, Size: 2725 bytes --]
Committed, thanks Juzhe.
Pan
From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai>
Sent: Thursday, November 9, 2023 2:54 PM
To: Li, Pan2 <pan2.li@intel.com>; gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Li, Pan2 <pan2.li@intel.com>; Wang, Yanzhang <yanzhang.wang@intel.com>; kito.cheng <kito.cheng@gmail.com>
Subject: Re: [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges
OK。
________________________________
juzhe.zhong@rivai.ai<mailto:juzhe.zhong@rivai.ai>
From: pan2.li<mailto:pan2.li@intel.com>
Date: 2023-11-09 14:50
To: gcc-patches<mailto:gcc-patches@gcc.gnu.org>
CC: juzhe.zhong<mailto:juzhe.zhong@rivai.ai>; pan2.li<mailto:pan2.li@intel.com>; yanzhang.wang<mailto:yanzhang.wang@intel.com>; kito.cheng<mailto:kito.cheng@gmail.com>
Subject: [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges
From: Pan Li <pan2.li@intel.com<mailto:pan2.li@intel.com>>
This patch would like to fine the frm insn emit when we
meet abnormal edge in the loop. Conceptually, we only need
to emit once when abnormal instead of every iteration in
the loop.
This patch would like to fix this defect and only perform
insert_insn_end_basic_block when at least one succ edge is
abnormal.
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_frm_emit_after_bb_end): Only
perform once emit when at least one succ edge is abnormal.
Signed-off-by: Pan Li <pan2.li@intel.com<mailto:pan2.li@intel.com>>
---
gcc/config/riscv/riscv.cc | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 08ff05dcc3f..e25692b86fc 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9348,20 +9348,33 @@ static void
riscv_frm_emit_after_bb_end (rtx_insn *cur_insn)
{
edge eg;
+ bool abnormal_edge_p = false;
edge_iterator eg_iterator;
basic_block bb = BLOCK_FOR_INSN (cur_insn);
FOR_EACH_EDGE (eg, eg_iterator, bb->succs)
+ {
+ if (eg->flags & EDGE_ABNORMAL)
+ abnormal_edge_p = true;
+ else
+ {
+ start_sequence ();
+ emit_insn (gen_frrmsi (DYNAMIC_FRM_RTL (cfun)));
+ rtx_insn *backup_insn = get_insns ();
+ end_sequence ();
+
+ insert_insn_on_edge (backup_insn, eg);
+ }
+ }
+
+ if (abnormal_edge_p)
{
start_sequence ();
emit_insn (gen_frrmsi (DYNAMIC_FRM_RTL (cfun)));
rtx_insn *backup_insn = get_insns ();
end_sequence ();
- if (eg->flags & EDGE_ABNORMAL)
- insert_insn_end_basic_block (backup_insn, bb);
- else
- insert_insn_on_edge (backup_insn, eg);
+ insert_insn_end_basic_block (backup_insn, bb);
}
commit_edge_insertions ();
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-09 12:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-09 6:50 [PATCH v1] RISC-V: Refine frm emit after bb end in succ edges pan2.li
2023-11-09 6:53 ` juzhe.zhong
2023-11-09 12:34 ` Li, Pan2
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).