public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Set 4 * (issue rate) as the default for -falign-functions and -falign-loops
@ 2023-04-18 12:17 Xi Ruoyao
  2023-04-18 12:39 ` WANG Xuerui
  2023-04-18 13:06 ` Lulu Cheng
  0 siblings, 2 replies; 11+ messages in thread
From: Xi Ruoyao @ 2023-04-18 12:17 UTC (permalink / raw)
  To: gcc-patches; +Cc: Lulu Cheng, WANG Xuerui, Chenghua Xu, Xi Ruoyao

According to Xuerui's LLVM changeset [1], doing so can make a
significant performace gain.

Bootstrapped and regtested on loongarch64-linux-gnu.  Ok for GCC 14?

[1]:https://reviews.llvm.org/D148622

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_option_override_internal): If -falign-functions is
	used but the alignment is not explicitly specified, set it to
	4 * loongarch_issue_rate ().  Likewise for -falign-loops.
---
 gcc/config/loongarch/loongarch.cc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 06fc1cd0604..6552484de7c 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -6236,6 +6236,17 @@ loongarch_option_override_internal (struct gcc_options *opts)
       && !opts->x_optimize_size)
     opts->x_flag_prefetch_loop_arrays = 1;
 
+  /* Align functions and loops to (issue rate) * (insn size) to improve
+     the throughput of the fetching units.  */
+  char *align = XNEWVEC (char, 16);
+  sprintf (align, "%d", loongarch_issue_rate () * 4);
+
+  if (opts->x_flag_align_functions && !opts->x_str_align_functions)
+    opts->x_str_align_functions = align;
+
+  if (opts->x_flag_align_loops && !opts->x_str_align_loops)
+    opts->x_str_align_loops = align;
+
   if (TARGET_DIRECT_EXTERN_ACCESS && flag_shlib)
     error ("%qs cannot be used for compiling a shared library",
 	   "-mdirect-extern-access");
-- 
2.40.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-06-13  2:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 12:17 [PATCH] LoongArch: Set 4 * (issue rate) as the default for -falign-functions and -falign-loops Xi Ruoyao
2023-04-18 12:39 ` WANG Xuerui
2023-04-18 12:45   ` Xi Ruoyao
2023-04-18 12:51     ` WANG Xuerui
2023-04-18 13:00       ` Xi Ruoyao
2023-04-18 13:06 ` Lulu Cheng
2023-04-18 13:16   ` Xi Ruoyao
2023-05-29  6:09   ` Xi Ruoyao
2023-05-30  1:30     ` Lulu Cheng
2023-06-12  9:19       ` Xi Ruoyao
2023-06-13  2:20         ` Lulu Cheng

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