LoongArch: Pass cache information to optimizer
Checks
Commit Message
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(+)
Comments
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");
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 :(.
在 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.
@@ -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");