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. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar 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 --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f11f0da28915f49829360cd7a6269e2a3f67a860..44eabb4f40262db9891e3bf501ec1cd049b3b294 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18979,6 +18979,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 2725c50da64a2c05489ea6202bdd5eedf1ba7e27..4dfd9b5c73011c73fcf8a39ad719ee9ca765297b 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 Undocumented 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. If both +-mautovec-preference and --param aarch64_autovec-preference are set then the +param value will be used. + mmax-vectorization Target Undocumented Var(flag_aarch64_max_vectorization) Save Override the scalar cost model such that vectorization is always profitable. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 54d4cf88cccd4d0e4ede3442ad9907faac325d52..88a93f9bc76687c415e0cce4c3431f1d91194dfc 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -21992,6 +21992,12 @@ precise control over which ISA will be used for auto-vectorization. Unlike -fno-vect-cost-model or -fvect-cost-model=unlimited this option does not turn off cost comparison between different vector modes. +@item -mautovec-preference=@var{name} +-mautovec-preference=[default|asimd-only|sve-only|prefer-asimd|prefer-sve] +Force an ISA selection strategy for auto-vectorization. If both +-mautovec-preference and --param aarch64_autovec-preference are set then the +param value will be used. + @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 0000000000000000000000000000000000000000..6aeac0b76f4bbdbb6dbaccfdfd061f004f031a21 --- /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 0000000000000000000000000000000000000000..589cc502fdadc98e10a81382de1fe2dd42b67321 --- /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 0000000000000000000000000000000000000000..ad89786499264a3c85edfd052b07a76af4a4e7fc --- /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 0000000000000000000000000000000000000000..2acea69e056d3cbb4be5649efeb3905e9117788d --- /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 0000000000000000000000000000000000000000..a7df0ebda8076f21152a405dc7fffc9022643659 --- /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) {} --
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index f11f0da28915f49829360cd7a6269e2a3f67a860..44eabb4f40262db9891e3bf501ec1cd049b3b294 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -18979,6 +18979,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 2725c50da64a2c05489ea6202bdd5eedf1ba7e27..4dfd9b5c73011c73fcf8a39ad719ee9ca765297b 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 Undocumented 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. If both +-mautovec-preference and --param aarch64_autovec-preference are set then the +param value will be used. + mmax-vectorization Target Undocumented Var(flag_aarch64_max_vectorization) Save Override the scalar cost model such that vectorization is always profitable. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 54d4cf88cccd4d0e4ede3442ad9907faac325d52..88a93f9bc76687c415e0cce4c3431f1d91194dfc 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -21992,6 +21992,12 @@ precise control over which ISA will be used for auto-vectorization. Unlike -fno-vect-cost-model or -fvect-cost-model=unlimited this option does not turn off cost comparison between different vector modes. +@item -mautovec-preference=@var{name} +-mautovec-preference=[default|asimd-only|sve-only|prefer-asimd|prefer-sve] +Force an ISA selection strategy for auto-vectorization. If both +-mautovec-preference and --param aarch64_autovec-preference are set then the +param value will be used. + @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 0000000000000000000000000000000000000000..6aeac0b76f4bbdbb6dbaccfdfd061f004f031a21 --- /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 0000000000000000000000000000000000000000..589cc502fdadc98e10a81382de1fe2dd42b67321 --- /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 0000000000000000000000000000000000000000..ad89786499264a3c85edfd052b07a76af4a4e7fc --- /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 0000000000000000000000000000000000000000..2acea69e056d3cbb4be5649efeb3905e9117788d --- /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 0000000000000000000000000000000000000000..a7df0ebda8076f21152a405dc7fffc9022643659 --- /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) {}