param_vect_scalar_cost_multiplier is support to make all vector loops profitable
and does so by scaling up the cost of a scalar iteration. However the new check
for uncounted loop profitability doesn't trigger it when we couldn't estimate
the scalar trip count.
This adjust the condition to check if the parameter is set to <= 100% scaling,
which means we want to make vector code more profitable and so bypass the check.
I've also considered that maybe the check should be something like <= 500% to
allow someone to use param_vect_scalar_cost_multiplier without immediately
enabling uncounted loops forcefully, but with a high multiplier enable it.
Most backends use a 100x multiplier so using <= 500% would work too if we think
it's useful.
Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues.
Any objections?
Thanks,
Tamar
gcc/ChangeLog:
* tree-vect-loop.cc (vect_analyze_loop_costing): Check scalar
cost multiplier.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/cost_model_19.c: New test.
---
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cost_model_19.c
b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_19.c
new file mode 100644
index
0000000000000000000000000000000000000000..9e4421d630f2b04833100f83dec378428b3d170f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_19.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -march=armv8-a+sve -mmax-vectorization -ffreestanding
-fdump-tree-vect-details" } */
+
+unsigned long f(const char *s)
+{
+ unsigned long i = 0;
+ while (*s++)
+ i++;
+ return i;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index
7121edb8d81904d227ba510f20a776fa7c9c8224..37fbbd1dc94e61d52b951eb4dd246776beeaad86
100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -1964,7 +1964,8 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo,
likely alignment prologue). */
if (LOOP_VINFO_NITERS_UNCOUNTED_P (loop_vinfo)
&& estimated_niter == -1
- && min_profitable_estimate > (int) vect_vf_for_cost (loop_vinfo))
+ && min_profitable_estimate > (int) vect_vf_for_cost (loop_vinfo)
+ && param_vect_scalar_cost_multiplier <= 100)
{
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
--
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cost_model_19.c b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_19.c
new file mode 100644
index 0000000000000000000000000000000000000000..9e4421d630f2b04833100f83dec378428b3d170f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_19.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -march=armv8-a+sve -mmax-vectorization -ffreestanding -fdump-tree-vect-details" } */
+
+unsigned long f(const char *s)
+{
+ unsigned long i = 0;
+ while (*s++)
+ i++;
+ return i;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops in function" "vect" } } */
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 7121edb8d81904d227ba510f20a776fa7c9c8224..37fbbd1dc94e61d52b951eb4dd246776beeaad86 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -1964,7 +1964,8 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo,
likely alignment prologue). */
if (LOOP_VINFO_NITERS_UNCOUNTED_P (loop_vinfo)
&& estimated_niter == -1
- && min_profitable_estimate > (int) vect_vf_for_cost (loop_vinfo))
+ && min_profitable_estimate > (int) vect_vf_for_cost (loop_vinfo)
+ && param_vect_scalar_cost_multiplier <= 100)
{
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,