]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AArch64: promote aarch64-autovec-peference to mautovec-preference
authorTamar Christina <tamar.christina@arm.com>
Tue, 24 Jun 2025 10:11:36 +0000 (11:11 +0100)
committerTamar Christina <tamar.christina@arm.com>
Tue, 24 Jun 2025 10:11:36 +0000 (11:11 +0100)
As requested in my patch for -mmax-vectorization this promotes the parameter
--param aarch64-autovec-preference to a first class top target flag.

If both the parameter and the flag is specified the parameter takes precedence
with the reasoning that it may already be embedded in build systems.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_override_options_internal): Set
value of parameter based on option.
* config/aarch64/aarch64.opt (autovec-preference): New.
* doc/invoke.texi (autovec-preference): Document it.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/autovec_param_asimd-only_2.c: New test.
* gcc.target/aarch64/autovec_param_default_2.c: New test.
* gcc.target/aarch64/autovec_param_prefer-asimd_2.c: New test.
* gcc.target/aarch64/autovec_param_prefer-sve_2.c: New test.
* gcc.target/aarch64/autovec_param_sve-only_2.c: New test.

gcc/config/aarch64/aarch64.cc
gcc/config/aarch64/aarch64.opt
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/aarch64/autovec_param_asimd-only_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/autovec_param_default_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-asimd_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-sve_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/autovec_param_sve-only_2.c [new file with mode: 0644]

index adbe05ac404aa78aa6ec2f5192bf8f75f69cb106..abbb97768f5e3a8a8ab310c909b2c6c82c6950c2 100644 (file)
@@ -19042,6 +19042,14 @@ aarch64_override_options_internal (struct gcc_options *opts)
     SET_OPTION_IF_UNSET (opts, &global_options_set,
                         param_vect_scalar_cost_multiplier, 10000);
 
+  /* Synchronize the -mautovec-preference and aarch64_autovec_preference using
+     whichever one is not default.  If both are set then prefer the param flag
+     over the parameters.  */
+  if (opts->x_autovec_preference != AARCH64_AUTOVEC_DEFAULT)
+    SET_OPTION_IF_UNSET (opts, &global_options_set,
+                        aarch64_autovec_preference,
+                        opts->x_autovec_preference);
+
   aarch64_override_options_after_change_1 (opts);
 }
 
index 17e1c700dd2b85e28012f3994d63f701656c5efb..9ca753e6a886149b40790a1f38077588c98f6465 100644 (file)
@@ -290,6 +290,13 @@ msve-vector-bits=
 Target RejectNegative Joined Enum(sve_vector_bits) Var(aarch64_sve_vector_bits) Init(SVE_SCALABLE)
 -msve-vector-bits=<number>     Set the number of bits in an SVE vector register.
 
+mautovec-preference=
+Target RejectNegative Joined Var(autovec_preference) Enum(aarch64_autovec_preference) Init(AARCH64_AUTOVEC_DEFAULT)
+-mautovec-preference=[default|asimd-only|sve-only|prefer-asimd|prefer-sve]
+Force an ISA selection strategy for auto-vectorization.  For best performance it
+is highly recommended to use -mcpu or -mtune instead.  This parameter should
+only be used for code exploration.
+
 mmax-vectorization
 Target Var(flag_aarch64_max_vectorization) Save
 Override the scalar cost model such that vectorization is always profitable.
@@ -360,8 +367,8 @@ The number of Newton iterations for calculating the reciprocal for double type.
 
 -param=aarch64-autovec-preference=
 Target Joined Var(aarch64_autovec_preference) Enum(aarch64_autovec_preference) Init(AARCH64_AUTOVEC_DEFAULT) Param
---param=aarch64-autovec-preference=[default|asimd-only|sve-only|prefer-asimd|prefer-sve]
-Force an ISA selection strategy for auto-vectorization.
+An old alias for -mautovec-preference.  If both -mautovec-preference and
+--param=aarch64-autovec-preference are passed, the --param value will be used.
 
 Enum
 Name(aarch64_autovec_preference) Type(enum aarch64_autovec_preference_enum) UnknownError(unknown autovec preference %qs)
index 93322778a5201d1509e434329e8b9594ecb2f386..a0c6d3d082e69d1a9837bcd6e3972b5a62633fee 100644 (file)
@@ -17627,20 +17627,9 @@ The precision of division is proportional to this param when division
 approximation is enabled.  The default value is 2.
 
 @item aarch64-autovec-preference
-Force an ISA selection strategy for auto-vectorization.
-@table @samp
-@item default
-Use the default heuristics.
-@item asimd-only
-Use only Advanced SIMD for auto-vectorization.
-@item sve-only
-Use only SVE for auto-vectorization.
-@item prefer-asimd
-Use both Advanced SIMD and SVE.  Prefer Advanced SIMD when the costs are
-deemed equal.
-@item prefer-sve
-Use both Advanced SIMD and SVE.  Prefer SVE when the costs are deemed equal.
-@end table
+An old alias for @option{-mautovec-preference}.  If both
+@option{-mautovec-preference} and @option{--param=aarch64-autovec-preference}
+are passed, the @option{--param} value will be used.
 
 @item aarch64-ldp-policy
 Fine-grained policy for load pairs.
@@ -22083,6 +22072,27 @@ used for auto-vectorization.  Unlike @option{-fno-vect-cost-model} or
 @option{-fvect-cost-model=unlimited} this option does not turn off cost
 comparison between different vector modes.
 
+@item -mautovec-preference=@var{name}
+Force an ISA selection strategy for auto-vectorization.  The possible
+values of @var{name} are:
+@table @samp
+@item default
+Use the default heuristics.
+@item asimd-only
+Use only Advanced SIMD for auto-vectorization.
+@item sve-only
+Use only SVE for auto-vectorization.
+@item prefer-asimd
+Use both Advanced SIMD and SVE.  Prefer Advanced SIMD when the costs are
+deemed equal.
+@item prefer-sve
+Use both Advanced SIMD and SVE.  Prefer SVE when the costs are deemed equal.
+@end table
+
+For best performance it is highly recommended to use @option{-mcpu} or
+@option{-mtune} instead.  This parameter should only be used for code
+exploration.
+
 @opindex march
 @item -march=@var{name}
 Specify the name of the target architecture and, optionally, one or
diff --git a/gcc/testsuite/gcc.target/aarch64/autovec_param_asimd-only_2.c b/gcc/testsuite/gcc.target/aarch64/autovec_param_asimd-only_2.c
new file mode 100644 (file)
index 0000000..6aeac0b
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-options "-mautovec-preference=asimd-only" } */
+
+void
+foo (void) {}
diff --git a/gcc/testsuite/gcc.target/aarch64/autovec_param_default_2.c b/gcc/testsuite/gcc.target/aarch64/autovec_param_default_2.c
new file mode 100644 (file)
index 0000000..589cc50
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-options "-mautovec-preference=default" } */
+
+void
+foo (void) {}
diff --git a/gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-asimd_2.c b/gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-asimd_2.c
new file mode 100644 (file)
index 0000000..ad89786
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-options "-mautovec-preference=prefer-asimd" } */
+
+void
+foo (void) {}
diff --git a/gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-sve_2.c b/gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-sve_2.c
new file mode 100644 (file)
index 0000000..2acea69
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-options "-mautovec-preference=prefer-sve" } */
+
+void
+foo (void) {}
diff --git a/gcc/testsuite/gcc.target/aarch64/autovec_param_sve-only_2.c b/gcc/testsuite/gcc.target/aarch64/autovec_param_sve-only_2.c
new file mode 100644 (file)
index 0000000..a7df0eb
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-options "-mautovec-preference=sve-only" } */
+
+void
+foo (void) {}