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

* Re: [PATCH] LoongArch: Pass cache information to optimizer
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Lulu Cheng @ 2022-09-26  7:04 UTC (permalink / raw)
  To: Xi Ruoyao, gcc-patches; +Cc: Wang Xuerui, Chenghua Xu

This change may have to wait for the test results to determine whether 
to merge.

在 2022/9/26 下午2:58, 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");


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

* Re: [PATCH] LoongArch: Pass cache information to optimizer
  2022-09-26  7:04 ` Lulu Cheng
@ 2022-09-27  3:16   ` Xi Ruoyao
  2022-09-27  3:54     ` Lulu Cheng
  0 siblings, 1 reply; 4+ messages in thread
From: Xi Ruoyao @ 2022-09-27  3:16 UTC (permalink / raw)
  To: Lulu Cheng, gcc-patches; +Cc: Wang Xuerui, Chenghua Xu

On Mon, 2022-09-26 at 15:04 +0800, Lulu Cheng wrote:
> This change may have to wait for the test results to determine whether
> to merge.

With this patch and my other pending patches

- https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602172.html
- https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602163.html

No regression from trunk:

$ diff -u ~/gcc-result-{unpatched,patched}  | grep '[+-]FAIL'   
-FAIL: gcc.dg/pr105414.c execution test
-FAIL: gcc.dg/pr106397.c (test for excess errors)

But if you mean "benchmark", yes I've not run any because I don't have
access to one :(.
-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

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

* Re: [PATCH] LoongArch: Pass cache information to optimizer
  2022-09-27  3:16   ` Xi Ruoyao
@ 2022-09-27  3:54     ` Lulu Cheng
  0 siblings, 0 replies; 4+ messages in thread
From: Lulu Cheng @ 2022-09-27  3:54 UTC (permalink / raw)
  To: Xi Ruoyao, gcc-patches; +Cc: Wang Xuerui, Chenghua Xu

在 2022/9/27 上午11:16, Xi Ruoyao 写道:

> On Mon, 2022-09-26 at 15:04 +0800, Lulu Cheng wrote:
>> This change may have to wait for the test results to determine whether
>> to merge.
> With this patch and my other pending patches
>
> - https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602172.html
> - https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602163.html
>
> No regression from trunk:
>
> $ diff -u ~/gcc-result-{unpatched,patched}  | grep '[+-]FAIL'
> -FAIL: gcc.dg/pr105414.c execution test
> -FAIL: gcc.dg/pr106397.c (test for excess errors)
>
> But if you mean "benchmark", yes I've not run any because I don't have
> access to one :(.

Yes, my colleague is testing the spec to see if this modification will 
cause some

of the spec's test case scores to drop.


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