public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8415] RISC-V: Add optim-no-fusion compile option [VSETVL PASS]
@ 2024-01-25  7:59 Pan Li
  0 siblings, 0 replies; only message in thread
From: Pan Li @ 2024-01-25  7:59 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1a8bebb1c59960590e7e2bc1a52757dfdd94210a

commit r14-8415-g1a8bebb1c59960590e7e2bc1a52757dfdd94210a
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Thu Jan 25 15:55:39 2024 +0800

    RISC-V: Add optim-no-fusion compile option [VSETVL PASS]
    
    This patch adds no fusion compile option to disable phase 2 global fusion.
    
    It can help us to analyze the compile-time and debugging.
    
    Committed.
    
    gcc/ChangeLog:
    
            * config/riscv/riscv-opts.h (enum vsetvl_strategy_enum): Add optim-no-fusion option.
            * config/riscv/riscv-vsetvl.cc (pass_vsetvl::lazy_vsetvl): Ditto.
            (pass_vsetvl::execute): Ditto.
            * config/riscv/riscv.opt: Ditto.

Diff:
---
 gcc/config/riscv/riscv-opts.h    |  8 +++++---
 gcc/config/riscv/riscv-vsetvl.cc | 22 ++++++++++++----------
 gcc/config/riscv/riscv.opt       |  5 ++++-
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h
index ca57dddf1d9..1500f8811ef 100644
--- a/gcc/config/riscv/riscv-opts.h
+++ b/gcc/config/riscv/riscv-opts.h
@@ -118,11 +118,13 @@ enum stringop_strategy_enum {
 
 /* Behavior of VSETVL Pass.  */
 enum vsetvl_strategy_enum {
-  /* Simple: Insert a vsetvl* instruction for each Vector instruction.  */
-  VSETVL_SIMPLE = 1,
   /* Optimized: Run LCM dataflow analysis to reduce vsetvl* insns and
      delete any redundant ones generated in the process.  */
-  VSETVL_OPT = 2
+  VSETVL_OPT,
+  /* Simple: Insert a vsetvl* instruction for each Vector instruction.  */
+  VSETVL_SIMPLE,
+  /* No fusion: Disable Phase 2 earliest global fusion.  */
+  VSETVL_OPT_NO_FUSION,
 };
 
 #define TARGET_ZICOND_LIKE (TARGET_ZICOND || (TARGET_XVENTANACONDOPS && TARGET_64BIT))
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 170fc7f003d..53d954e1dff 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -3495,16 +3495,18 @@ pass_vsetvl::lazy_vsetvl ()
   /* Phase 2:  Fuse header and footer vsetvl infos between basic blocks.  */
   if (dump_file)
     fprintf (dump_file, "\nPhase 2: Lift up vsetvl info.\n\n");
-  bool changed;
-  int fused_count = 0;
-  do
+  if (vsetvl_strategy != VSETVL_OPT_NO_FUSION)
     {
-      if (dump_file)
-	fprintf (dump_file, "  Try lift up %d.\n\n", fused_count);
-      changed = pre.earliest_fuse_vsetvl_info (fused_count);
-      fused_count += 1;
-  } while (changed);
-
+      bool changed = true;
+      int fused_count = 0;
+      do
+	{
+	  if (dump_file)
+	    fprintf (dump_file, "  Try lift up %d.\n\n", fused_count);
+	  changed = pre.earliest_fuse_vsetvl_info (fused_count);
+	  fused_count += 1;
+      } while (changed);
+    }
   if (dump_file && (dump_flags & TDF_DETAILS))
     pre.dump (dump_file, "phase 2");
 
@@ -3545,7 +3547,7 @@ pass_vsetvl::execute (function *)
   if (!has_vector_insn (cfun))
     return 0;
 
-  if (!optimize || vsetvl_strategy & VSETVL_SIMPLE)
+  if (!optimize || vsetvl_strategy == VSETVL_SIMPLE)
     simple_vsetvl ();
   else
     lazy_vsetvl ();
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index 65c656204ca..7c2292d8f91 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -552,11 +552,14 @@ Enum
 Name(vsetvl_strategy) Type(enum vsetvl_strategy_enum)
 Valid arguments to -param=vsetvl-strategy=:
 
+EnumValue
+Enum(vsetvl_strategy) String(optim) Value(VSETVL_OPT)
+
 EnumValue
 Enum(vsetvl_strategy) String(simple) Value(VSETVL_SIMPLE)
 
 EnumValue
-Enum(vsetvl_strategy) String(optim) Value(VSETVL_OPT)
+Enum(vsetvl_strategy) String(optim-no-fusion) Value(VSETVL_OPT_NO_FUSION)
 
 -param=vsetvl-strategy=
 Target Undocumented RejectNegative Joined Enum(vsetvl_strategy) Var(vsetvl_strategy) Init(VSETVL_OPT)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-25  7:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25  7:59 [gcc r14-8415] RISC-V: Add optim-no-fusion compile option [VSETVL PASS] Pan Li

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).