Hi,
The default rs6000_min_insns_constant_in_pool is 2, which would suitable
for a few cases. While for different targets, we can tune this threshold
slightly.
For example, 'pld' could load a constant value from memory as faster as
building a constant by one instruction, and faster than build a constant
through two instructions.
This patch tune the parameter rs6000_min_insns_constant_in_pool for
TARGET_PREFIXED and TARGET_32BIT.
Bootstrap and regtest pass on ppc64 and ppc64le.
Is this patch ok for trunk?
BR,
Jeff(Jiufu) Guo
gcc/ChangeLog:
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Tune
rs6000_min_insns_constant_in_pool.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/const-build-1.c: Keep original test point
by using rs6000_min_insns_constant_in_pool.
* gcc.target/powerpc/const-build.c: Likewise.
---
gcc/config/rs6000/rs6000.cc | 15 +++++++++++++++
gcc/testsuite/gcc.target/powerpc/const-build-1.c | 2 +-
gcc/testsuite/gcc.target/powerpc/const-build.c | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index c785fb20b1b..632760dc814 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -4847,6 +4847,21 @@ rs6000_option_override_internal (bool global_init_p)
warning (0, "%qs is deprecated and not recommended in any circumstances",
"-mno-speculate-indirect-jumps");
+ /* Set the threshold for how complicated constant should be put
+ into constant pool. */
+ if (!OPTION_SET_P (rs6000_min_insns_constant_in_pool))
+ {
+ /* one insn could load for the constant: pld 3, .LC1@pcrel
+ ld 0,.LC1@toc(2). */
+ if (TARGET_PREFIXED || (TARGET_64BIT && TARGET_CMODEL == CMODEL_SMALL))
+ rs6000_min_insns_constant_in_pool = 1;
+
+ /* Consider address addjust, slight increase the threshold:
+ add 30,0,30; lwz 9,.LC1-.LCTOC1(30); ld 9,0(9); or
+ lis 9,.LC0@ha; la 9,.LC0@l(9); ld 9,0(9)*/
+ else if (TARGET_32BIT && flag_pic != 1)
+ rs6000_min_insns_constant_in_pool = 3;
+ }
return ret;
}
diff --git a/gcc/testsuite/gcc.target/powerpc/const-build-1.c
b/gcc/testsuite/gcc.target/powerpc/const-build-1.c
index 7e35f8c507f..e7061709fea 100644
--- a/gcc/testsuite/gcc.target/powerpc/const-build-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/const-build-1.c
@@ -1,5 +1,5 @@
/* { dg-do compile { target lp64 } } */
-/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10
--param=rs6000-min-insns-constant-in-pool=2" } */
/* { dg-require-effective-target power10_ok } */
unsigned long long msk66() { return 0x6666666666666666ULL; }
diff --git a/gcc/testsuite/gcc.target/powerpc/const-build.c
b/gcc/testsuite/gcc.target/powerpc/const-build.c
index 52941ca4c2f..31e1a611243 100644
--- a/gcc/testsuite/gcc.target/powerpc/const-build.c
+++ b/gcc/testsuite/gcc.target/powerpc/const-build.c
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-O2 -save-temps" } */
+/* { dg-options "-O2 -save-temps --param=rs6000-min-insns-constant-in-pool=2"
} */
/* { dg-require-effective-target has_arch_ppc64 } */
/* Verify that two instructions are successfully used to build constants.
--
2.43.0