public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Pass cache information to optimizer
@ 2022-09-26  6:58 Xi Ruoyao
  2022-09-26  7:04 ` Lulu Cheng
  0 siblings, 1 reply; 4+ messages in thread
From: Xi Ruoyao @ 2022-09-26  6:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Lulu Cheng, Wang Xuerui, Chenghua Xu, Xi Ruoyao

Currently our cache information from -mtune is not really used, pass it
to the optimizer so it will be really in-effect.

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_option_override_internal): Set the corresponding
	params for L1D cache line size, L1D cache size, and L2D cache
	size.
---
 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 98c0e26cdb9..81594cf5b98 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "context.h"
 #include "builtins.h"
 #include "rtl-iter.h"
+#include "opts.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -6096,6 +6097,16 @@ loongarch_option_override_internal (struct gcc_options *opts)
   if (loongarch_branch_cost == 0)
     loongarch_branch_cost = loongarch_cost->branch_cost;
 
+  const loongarch_cache &tune_cache =
+    loongarch_cpu_cache[la_target.cpu_tune];
+
+  SET_OPTION_IF_UNSET (opts, &global_options_set, param_l1_cache_line_size,
+		       tune_cache.l1d_line_size);
+  SET_OPTION_IF_UNSET (opts, &global_options_set, param_l1_cache_size,
+		       tune_cache.l1d_size);
+  SET_OPTION_IF_UNSET (opts, &global_options_set, param_l2_cache_size,
+		       tune_cache.l2d_size);
+
   if (TARGET_DIRECT_EXTERN_ACCESS && flag_shlib)
     error ("%qs cannot be used for compiling a shared library",
 	   "-mdirect-extern-access");
-- 
2.37.0


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

end of thread, other threads:[~2022-09-27  3:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-26  6:58 [PATCH] LoongArch: Pass cache information to optimizer Xi Ruoyao
2022-09-26  7:04 ` Lulu Cheng
2022-09-27  3:16   ` Xi Ruoyao
2022-09-27  3:54     ` 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).