https://gcc.gnu.org/g:f60d3f5cf15abc32e167e3c00f79c4ab6d00ec38
commit r16-1650-gf60d3f5cf15abc32e167e3c00f79c4ab6d00ec38 Author: Tamar Christina <tamar.christ...@arm.com> Date: Tue Jun 24 11:11:36 2025 +0100 AArch64: promote aarch64-autovec-peference to mautovec-preference 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. Diff: --- gcc/config/aarch64/aarch64.cc | 8 +++++ gcc/config/aarch64/aarch64.opt | 11 +++++-- gcc/doc/invoke.texi | 38 ++++++++++++++-------- .../aarch64/autovec_param_asimd-only_2.c | 4 +++ .../gcc.target/aarch64/autovec_param_default_2.c | 4 +++ .../aarch64/autovec_param_prefer-asimd_2.c | 4 +++ .../aarch64/autovec_param_prefer-sve_2.c | 4 +++ .../gcc.target/aarch64/autovec_param_sve-only_2.c | 4 +++ 8 files changed, 61 insertions(+), 16 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index adbe05ac404a..abbb97768f5e 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -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); } diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt index 17e1c700dd2b..9ca753e6a886 100644 --- a/gcc/config/aarch64/aarch64.opt +++ b/gcc/config/aarch64/aarch64.opt @@ -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) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 93322778a520..a0c6d3d082e6 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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 index 000000000000..6aeac0b76f4b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/autovec_param_asimd-only_2.c @@ -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 index 000000000000..589cc502fdad --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/autovec_param_default_2.c @@ -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 index 000000000000..ad8978649926 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-asimd_2.c @@ -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 index 000000000000..2acea69e056d --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/autovec_param_prefer-sve_2.c @@ -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 index 000000000000..a7df0ebda807 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/autovec_param_sve-only_2.c @@ -0,0 +1,4 @@ +/* { dg-options "-mautovec-preference=sve-only" } */ + +void +foo (void) {}