]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Refine frm emit after bb end in succ edges
authorPan Li <pan2.li@intel.com>
Thu, 9 Nov 2023 06:42:04 +0000 (14:42 +0800)
committerPan Li <pan2.li@intel.com>
Thu, 9 Nov 2023 12:33:34 +0000 (20:33 +0800)
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

index 08ff05dcc3f9f98190ce4cdd8a85b5c47e55645f..e25692b86fc183c0b4f55e35d089e0e7b2a82a1a 100644 (file)
@@ -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 ();