Improves on: 834fc2bf This improves the code structure of the ldp-stp policies patch introduced in 834fc2bf
Bootstrapped and regtested on aarch64-linux. gcc/ChangeLog: * config/aarch64/aarch64-opts.h (enum aarch64_ldp_policy): Added AARCH64 prefix. (enum aarch64_stp_policy): Added AARCH64 prefix. * config/aarch64/aarch64-protos.h (struct tune_params): Merged enums aarch64_ldp_policy_model and aarch64_stp_policy_model to aarch64_ldp_stp_policy_model. * config/aarch64/aarch64.cc (aarch64_parse_ldp_policy): Removed. (aarch64_parse_ldp_stp_policy): New function. (aarch64_parse_stp_policy): Removed. (aarch64_override_options_internal): Added call to new parsing function and removed superseded ones. (aarch64_mem_ok_with_ldpstp_policy_model): Improved code quality based on the new changes. * config/aarch64/aarch64.opt: Added AARCH64 prefix. gcc/testsuite/ChangeLog: * gcc.target/aarch64/ldp_aligned.c: Splitted into this and ldp_unaligned. * gcc.target/aarch64/stp_aligned.c: Splitted into this and stp_unaligned. * gcc.target/aarch64/ldp_unaligned.c: New test. * gcc.target/aarch64/stp_unaligned.c: New test. Signed-off-by: Manos Anagnostakis <manos.anagnosta...@vrull.eu> --- gcc/config/aarch64/aarch64-opts.h | 16 +- gcc/config/aarch64/aarch64-protos.h | 30 +-- gcc/config/aarch64/aarch64.cc | 184 ++++++++---------- gcc/config/aarch64/aarch64.opt | 20 +- .../gcc.target/aarch64/ldp_aligned.c | 28 --- .../gcc.target/aarch64/ldp_unaligned.c | 40 ++++ .../gcc.target/aarch64/stp_aligned.c | 25 --- .../gcc.target/aarch64/stp_unaligned.c | 37 ++++ 8 files changed, 189 insertions(+), 191 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/ldp_unaligned.c create mode 100644 gcc/testsuite/gcc.target/aarch64/stp_unaligned.c diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h index db8348507a3..e23e1ea200e 100644 --- a/gcc/config/aarch64/aarch64-opts.h +++ b/gcc/config/aarch64/aarch64-opts.h @@ -110,18 +110,18 @@ enum aarch64_key_type { /* Load pair policy type. */ enum aarch64_ldp_policy { - LDP_POLICY_DEFAULT, - LDP_POLICY_ALWAYS, - LDP_POLICY_NEVER, - LDP_POLICY_ALIGNED + AARCH64_LDP_POLICY_DEFAULT, + AARCH64_LDP_POLICY_ALWAYS, + AARCH64_LDP_POLICY_NEVER, + AARCH64_LDP_POLICY_ALIGNED }; /* Store pair policy type. */ enum aarch64_stp_policy { - STP_POLICY_DEFAULT, - STP_POLICY_ALWAYS, - STP_POLICY_NEVER, - STP_POLICY_ALIGNED + AARCH64_STP_POLICY_DEFAULT, + AARCH64_STP_POLICY_ALWAYS, + AARCH64_STP_POLICY_NEVER, + AARCH64_STP_POLICY_ALIGNED }; #endif diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 5c6802b4fe8..7d19111a215 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -568,30 +568,20 @@ struct tune_params /* Place prefetch struct pointer at the end to enable type checking errors when tune_params misses elements (e.g., from erroneous merges). */ const struct cpu_prefetch_tune *prefetch; -/* An enum specifying how to handle load pairs using a fine-grained policy: - - LDP_POLICY_ALIGNED: Emit ldp if the source pointer is aligned - to at least double the alignment of the type. - - LDP_POLICY_ALWAYS: Emit ldp regardless of alignment. - - LDP_POLICY_NEVER: Do not emit ldp. */ - enum aarch64_ldp_policy_model - { - LDP_POLICY_ALIGNED, - LDP_POLICY_ALWAYS, - LDP_POLICY_NEVER - } ldp_policy_model; -/* An enum specifying how to handle store pairs using a fine-grained policy: - - STP_POLICY_ALIGNED: Emit stp if the source pointer is aligned +/* An enum specifying how to handle load and store pairs using + a fine-grained policy: + - LDP_STP_POLICY_ALIGNED: Emit ldp/stp if the source pointer is aligned to at least double the alignment of the type. - - STP_POLICY_ALWAYS: Emit stp regardless of alignment. - - STP_POLICY_NEVER: Do not emit stp. */ + - LDP_STP_POLICY_ALWAYS: Emit ldp/stp regardless of alignment. + - LDP_STP_POLICY_NEVER: Do not emit ldp/stp. */ - enum aarch64_stp_policy_model + enum aarch64_ldp_stp_policy_model { - STP_POLICY_ALIGNED, - STP_POLICY_ALWAYS, - STP_POLICY_NEVER - } stp_policy_model; + AARCH64_LDP_STP_POLICY_ALIGNED, + AARCH64_LDP_STP_POLICY_ALWAYS, + AARCH64_LDP_STP_POLICY_NEVER + } ldp_policy_model, stp_policy_model; }; /* Classifies an address. diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index aa920fc703a..8edc4c18643 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -1358,8 +1358,8 @@ static const struct tune_params generic_tunings = have at most a very minor effect on SVE2 cores. */ (AARCH64_EXTRA_TUNE_CSE_SVE_VL_CONSTANTS), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params cortexa35_tunings = @@ -1394,8 +1394,8 @@ static const struct tune_params cortexa35_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params cortexa53_tunings = @@ -1430,8 +1430,8 @@ static const struct tune_params cortexa53_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params cortexa57_tunings = @@ -1466,8 +1466,8 @@ static const struct tune_params cortexa57_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_RENAME_FMA_REGS), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params cortexa72_tunings = @@ -1502,8 +1502,8 @@ static const struct tune_params cortexa72_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params cortexa73_tunings = @@ -1538,12 +1538,10 @@ static const struct tune_params cortexa73_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; - - static const struct tune_params exynosm1_tunings = { &exynosm1_extra_costs, @@ -1575,8 +1573,8 @@ static const struct tune_params exynosm1_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &exynosm1_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params thunderxt88_tunings = @@ -1610,8 +1608,8 @@ static const struct tune_params thunderxt88_tunings = tune_params::AUTOPREFETCHER_OFF, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &thunderxt88_prefetch_tune, - tune_params::LDP_POLICY_ALIGNED, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALIGNED /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED /* stp_policy_model. */ }; static const struct tune_params thunderx_tunings = @@ -1645,8 +1643,8 @@ static const struct tune_params thunderx_tunings = tune_params::AUTOPREFETCHER_OFF, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_CHEAP_SHIFT_EXTEND), /* tune_flags. */ &thunderx_prefetch_tune, - tune_params::LDP_POLICY_ALIGNED, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALIGNED /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED /* stp_policy_model. */ }; static const struct tune_params tsv110_tunings = @@ -1681,8 +1679,8 @@ static const struct tune_params tsv110_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &tsv110_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params xgene1_tunings = @@ -1716,8 +1714,8 @@ static const struct tune_params xgene1_tunings = tune_params::AUTOPREFETCHER_OFF, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS), /* tune_flags. */ &xgene1_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params emag_tunings = @@ -1751,8 +1749,8 @@ static const struct tune_params emag_tunings = tune_params::AUTOPREFETCHER_OFF, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NO_LDP_STP_QREGS), /* tune_flags. */ &xgene1_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params qdf24xx_tunings = @@ -1787,8 +1785,8 @@ static const struct tune_params qdf24xx_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ AARCH64_EXTRA_TUNE_RENAME_LOAD_REGS, /* tune_flags. */ &qdf24xx_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; /* Tuning structure for the Qualcomm Saphira core. Default to falkor values @@ -1825,8 +1823,8 @@ static const struct tune_params saphira_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params thunderx2t99_tunings = @@ -1861,8 +1859,8 @@ static const struct tune_params thunderx2t99_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &thunderx2t99_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params thunderx3t110_tunings = @@ -1897,8 +1895,8 @@ static const struct tune_params thunderx3t110_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &thunderx3t110_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params neoversen1_tunings = @@ -1932,8 +1930,8 @@ static const struct tune_params neoversen1_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_CHEAP_SHIFT_EXTEND), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params ampere1_tunings = @@ -1971,8 +1969,8 @@ static const struct tune_params ampere1_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &ere1_prefetch_tune, - tune_params::LDP_POLICY_ALIGNED, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALIGNED /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED /* stp_policy_model. */ }; static const struct tune_params ampere1a_tunings = @@ -2011,8 +2009,8 @@ static const struct tune_params ampere1a_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &ere1_prefetch_tune, - tune_params::LDP_POLICY_ALIGNED, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALIGNED /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALIGNED /* stp_policy_model. */ }; static const advsimd_vec_cost neoversev1_advsimd_vector_cost = @@ -2194,8 +2192,8 @@ static const struct tune_params neoversev1_tunings = | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT | AARCH64_EXTRA_TUNE_CHEAP_SHIFT_EXTEND), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const sve_vec_cost neoverse512tvb_sve_vector_cost = @@ -2333,8 +2331,8 @@ static const struct tune_params neoverse512tvb_tunings = | AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const advsimd_vec_cost neoversen2_advsimd_vector_cost = @@ -2525,8 +2523,8 @@ static const struct tune_params neoversen2_tunings = | AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const advsimd_vec_cost neoversev2_advsimd_vector_cost = @@ -2717,8 +2715,8 @@ static const struct tune_params neoversev2_tunings = | AARCH64_EXTRA_TUNE_USE_NEW_VECTOR_COSTS | AARCH64_EXTRA_TUNE_MATCHED_VECTOR_THROUGHPUT), /* tune_flags. */ &generic_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; static const struct tune_params a64fx_tunings = @@ -2752,8 +2750,8 @@ static const struct tune_params a64fx_tunings = tune_params::AUTOPREFETCHER_WEAK, /* autoprefetcher_model. */ (AARCH64_EXTRA_TUNE_NONE), /* tune_flags. */ &a64fx_prefetch_tune, - tune_params::LDP_POLICY_ALWAYS, /* ldp_policy_model. */ - tune_params::STP_POLICY_ALWAYS /* stp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS, /* ldp_policy_model. */ + tune_params::AARCH64_LDP_STP_POLICY_ALWAYS /* stp_policy_model. */ }; /* Support for fine-grained override of the tuning structures. */ @@ -17866,34 +17864,35 @@ aarch64_parse_tune (const char *to_parse, const struct processor **res) return AARCH_PARSE_INVALID_ARG; } -/* Parse a command-line -param=aarch64-ldp-policy= parameter. VALUE is - the value of the parameter. */ +/* Parse command-line -param=aarch64-ldp-policy= and + -param=aarch64-stp-policy= parameters. LDP_VALUE is the value + of the ldp-policy parameter and STP_VALUE is the value + of the stp-policy parameter. */ static void -aarch64_parse_ldp_policy (enum aarch64_ldp_policy value, - struct tune_params* tune) +aarch64_parse_ldp_stp_policy (enum aarch64_ldp_policy ldp_value, + enum aarch64_stp_policy stp_value, + struct tune_params* tune) { - if (value == LDP_POLICY_ALWAYS) - tune->ldp_policy_model = tune_params::LDP_POLICY_ALWAYS; - else if (value == LDP_POLICY_NEVER) - tune->ldp_policy_model = tune_params::LDP_POLICY_NEVER; - else if (value == LDP_POLICY_ALIGNED) - tune->ldp_policy_model = tune_params::LDP_POLICY_ALIGNED; -} - -/* Parse a command-line -param=aarch64-stp-policy= parameter. VALUE is - the value of the parameter. */ + if (ldp_value != AARCH64_LDP_POLICY_DEFAULT) + { + if (ldp_value == AARCH64_LDP_POLICY_ALWAYS) + tune->ldp_policy_model = tune_params::AARCH64_LDP_STP_POLICY_ALWAYS; + else if (ldp_value == AARCH64_LDP_POLICY_NEVER) + tune->ldp_policy_model = tune_params::AARCH64_LDP_STP_POLICY_NEVER; + else if (ldp_value == AARCH64_LDP_POLICY_ALIGNED) + tune->ldp_policy_model = tune_params::AARCH64_LDP_STP_POLICY_ALIGNED; + } -static void -aarch64_parse_stp_policy (enum aarch64_stp_policy value, - struct tune_params* tune) -{ - if (value == STP_POLICY_ALWAYS) - tune->stp_policy_model = tune_params::STP_POLICY_ALWAYS; - else if (value == STP_POLICY_NEVER) - tune->stp_policy_model = tune_params::STP_POLICY_NEVER; - else if (value == STP_POLICY_ALIGNED) - tune->stp_policy_model = tune_params::STP_POLICY_ALIGNED; + if (stp_value != AARCH64_STP_POLICY_DEFAULT) + { + if (stp_value == AARCH64_STP_POLICY_ALWAYS) + tune->stp_policy_model = tune_params::AARCH64_LDP_STP_POLICY_ALWAYS; + else if (stp_value == AARCH64_STP_POLICY_NEVER) + tune->stp_policy_model = tune_params::AARCH64_LDP_STP_POLICY_NEVER; + else if (stp_value == AARCH64_STP_POLICY_ALIGNED) + tune->stp_policy_model = tune_params::AARCH64_LDP_STP_POLICY_ALIGNED; + } } /* Parse TOKEN, which has length LENGTH to see if it is an option @@ -18244,13 +18243,10 @@ aarch64_override_options_internal (struct gcc_options *opts) aarch64_parse_override_string (opts->x_aarch64_override_tune_string, &aarch64_tune_params); - if (opts->x_aarch64_ldp_policy_param) - aarch64_parse_ldp_policy (opts->x_aarch64_ldp_policy_param, - &aarch64_tune_params); - - if (opts->x_aarch64_stp_policy_param) - aarch64_parse_stp_policy (opts->x_aarch64_stp_policy_param, - &aarch64_tune_params); + if (opts->x_aarch64_ldp_policy_param || opts->x_aarch64_stp_policy_param) + aarch64_parse_ldp_stp_policy (opts->x_aarch64_ldp_policy_param, + opts->x_aarch64_stp_policy_param, + &aarch64_tune_params); /* This target defaults to strict volatile bitfields. */ if (opts->x_flag_strict_volatile_bitfields < 0 && abi_version_at_least (2)) @@ -26551,30 +26547,18 @@ aarch64_mergeable_load_pair_p (machine_mode mode, rtx mem1, rtx mem2) bool aarch64_mem_ok_with_ldpstp_policy_model (rtx mem, bool load, machine_mode mode) { - /* If we have LDP_POLICY_NEVER, reject the load pair. */ - if (load - && aarch64_tune_params.ldp_policy_model == tune_params::LDP_POLICY_NEVER) - return false; + auto policy = (load + ? aarch64_tune_params.ldp_policy_model + : aarch64_tune_params.stp_policy_model); - /* If we have STP_POLICY_NEVER, reject the store pair. */ - if (!load - && aarch64_tune_params.stp_policy_model == tune_params::STP_POLICY_NEVER) + /* If we have AARCH64_LDP_STP_POLICY_NEVER, reject the load pair. */ + if (policy == tune_params::AARCH64_LDP_STP_POLICY_NEVER) return false; - /* If we have LDP_POLICY_ALIGNED, + /* If we have AARCH64_LDP_STP_POLICY_ALIGNED, do not emit the load pair unless the alignment is checked to be at least double the alignment of the type. */ - if (load - && aarch64_tune_params.ldp_policy_model == tune_params::LDP_POLICY_ALIGNED - && !optimize_function_for_size_p (cfun) - && MEM_ALIGN (mem) < 2 * GET_MODE_ALIGNMENT (mode)) - return false; - - /* If we have STP_POLICY_ALIGNED, - do not emit the store pair unless the alignment is checked to be - at least double the alignment of the type. */ - if (!load - && aarch64_tune_params.stp_policy_model == tune_params::STP_POLICY_ALIGNED + if (policy == tune_params::AARCH64_LDP_STP_POLICY_ALIGNED && !optimize_function_for_size_p (cfun) && MEM_ALIGN (mem) < 2 * GET_MODE_ALIGNMENT (mode)) return false; diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt index 2101c5a23c4..58b834f967b 100644 --- a/gcc/config/aarch64/aarch64.opt +++ b/gcc/config/aarch64/aarch64.opt @@ -339,39 +339,39 @@ Target Joined UInteger Var(aarch64_vect_unroll_limit) Init(4) Param Limit how much the autovectorizer may unroll a loop. -param=aarch64-ldp-policy= -Target Joined Var(aarch64_ldp_policy_param) Enum(aarch64_ldp_policy) Init(LDP_POLICY_DEFAULT) Param +Target Joined Var(aarch64_ldp_policy_param) Enum(aarch64_ldp_policy) Init(AARCH64_LDP_POLICY_DEFAULT) Param --param=aarch64-ldp-policy=[default|always|never|aligned] Fine-grained policy for load pairs. Enum Name(aarch64_ldp_policy) Type(enum aarch64_ldp_policy) UnknownError(unknown aarch64_ldp_policy mode %qs) EnumValue -Enum(aarch64_ldp_policy) String(default) Value(LDP_POLICY_DEFAULT) +Enum(aarch64_ldp_policy) String(default) Value(AARCH64_LDP_POLICY_DEFAULT) EnumValue -Enum(aarch64_ldp_policy) String(always) Value(LDP_POLICY_ALWAYS) +Enum(aarch64_ldp_policy) String(always) Value(AARCH64_LDP_POLICY_ALWAYS) EnumValue -Enum(aarch64_ldp_policy) String(never) Value(LDP_POLICY_NEVER) +Enum(aarch64_ldp_policy) String(never) Value(AARCH64_LDP_POLICY_NEVER) EnumValue -Enum(aarch64_ldp_policy) String(aligned) Value(LDP_POLICY_ALIGNED) +Enum(aarch64_ldp_policy) String(aligned) Value(AARCH64_LDP_POLICY_ALIGNED) -param=aarch64-stp-policy= -Target Joined Var(aarch64_stp_policy_param) Enum(aarch64_stp_policy) Init(STP_POLICY_DEFAULT) Param +Target Joined Var(aarch64_stp_policy_param) Enum(aarch64_stp_policy) Init(AARCH64_STP_POLICY_DEFAULT) Param --param=aarch64-stp-policy=[default|always|never|aligned] Fine-grained policy for store pairs. Enum Name(aarch64_stp_policy) Type(enum aarch64_stp_policy) UnknownError(unknown aarch64_stp_policy mode %qs) EnumValue -Enum(aarch64_stp_policy) String(default) Value(STP_POLICY_DEFAULT) +Enum(aarch64_stp_policy) String(default) Value(AARCH64_STP_POLICY_DEFAULT) EnumValue -Enum(aarch64_stp_policy) String(always) Value(STP_POLICY_ALWAYS) +Enum(aarch64_stp_policy) String(always) Value(AARCH64_STP_POLICY_ALWAYS) EnumValue -Enum(aarch64_stp_policy) String(never) Value(STP_POLICY_NEVER) +Enum(aarch64_stp_policy) String(never) Value(AARCH64_STP_POLICY_NEVER) EnumValue -Enum(aarch64_stp_policy) String(aligned) Value(STP_POLICY_ALIGNED) +Enum(aarch64_stp_policy) String(aligned) Value(AARCH64_STP_POLICY_ALIGNED) diff --git a/gcc/testsuite/gcc.target/aarch64/ldp_aligned.c b/gcc/testsuite/gcc.target/aarch64/ldp_aligned.c index f44f9616366..75495d71df2 100644 --- a/gcc/testsuite/gcc.target/aarch64/ldp_aligned.c +++ b/gcc/testsuite/gcc.target/aarch64/ldp_aligned.c @@ -14,16 +14,6 @@ TYPE ldp_aligned_##TYPE(char* ptr){ \ return a_0 + a_1; \ } -#define LDP_TEST_UNALIGNED(TYPE) \ -TYPE ldp_unaligned_##TYPE(char* ptr){ \ - TYPE a_0, a_1; \ - TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ - TYPE *a = arr+1; \ - a_0 = a[0]; \ - a_1 = a[1]; \ - return a_0 + a_1; \ -} - #define LDP_TEST_ADJUST_ALIGNED(TYPE) \ TYPE ldp_aligned_adjust_##TYPE(char* ptr){ \ TYPE a_0, a_1, a_2, a_3, a_4; \ @@ -36,29 +26,11 @@ TYPE ldp_aligned_adjust_##TYPE(char* ptr){ \ return a_0 + a_1 + a_2 + a_3 + a_4; \ } -#define LDP_TEST_ADJUST_UNALIGNED(TYPE) \ -TYPE ldp_unaligned_adjust_##TYPE(char* ptr){ \ - TYPE a_0, a_1, a_2, a_3, a_4; \ - TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ - TYPE *a = arr+1; \ - a_0 = a[100]; \ - a_1 = a[101]; \ - a_2 = a[102]; \ - a_3 = a[103]; \ - a_4 = a[110]; \ - return a_0 + a_1 + a_2 + a_3 + a_4; \ -} - LDP_TEST_ALIGNED(int32_t); LDP_TEST_ALIGNED(int64_t); LDP_TEST_ALIGNED(v4si); -LDP_TEST_UNALIGNED(int32_t); -LDP_TEST_UNALIGNED(int64_t); -LDP_TEST_UNALIGNED(v4si); LDP_TEST_ADJUST_ALIGNED(int32_t); LDP_TEST_ADJUST_ALIGNED(int64_t); -LDP_TEST_ADJUST_UNALIGNED(int32_t); -LDP_TEST_ADJUST_UNALIGNED(int64_t); /* { dg-final { scan-assembler-times "ldp\tw\[0-9\]+, w\[0-9\]" 3 } } */ /* { dg-final { scan-assembler-times "ldp\tx\[0-9\]+, x\[0-9\]" 3 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/ldp_unaligned.c b/gcc/testsuite/gcc.target/aarch64/ldp_unaligned.c new file mode 100644 index 00000000000..d9dcfe432f0 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/ldp_unaligned.c @@ -0,0 +1,40 @@ +/* { dg-options "-O2 --param=aarch64-ldp-policy=aligned -mcpu=generic" } */ + +#include <stdlib.h> +#include <stdint.h> + +typedef int v4si __attribute__ ((vector_size (16))); + +#define LDP_TEST_UNALIGNED(TYPE) \ +TYPE ldp_unaligned_##TYPE(char* ptr){ \ + TYPE a_0, a_1; \ + TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ + TYPE *a = arr+1; \ + a_0 = a[0]; \ + a_1 = a[1]; \ + return a_0 + a_1; \ +} + +#define LDP_TEST_ADJUST_UNALIGNED(TYPE) \ +TYPE ldp_unaligned_adjust_##TYPE(char* ptr){ \ + TYPE a_0, a_1, a_2, a_3, a_4; \ + TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ + TYPE *a = arr+1; \ + a_0 = a[100]; \ + a_1 = a[101]; \ + a_2 = a[102]; \ + a_3 = a[103]; \ + a_4 = a[110]; \ + return a_0 + a_1 + a_2 + a_3 + a_4; \ +} + +LDP_TEST_UNALIGNED(int32_t); +LDP_TEST_UNALIGNED(int64_t); +LDP_TEST_UNALIGNED(v4si); +LDP_TEST_ADJUST_UNALIGNED(int32_t); +LDP_TEST_ADJUST_UNALIGNED(int64_t); + +/* { dg-final { scan-assembler-times "ldp\tw\[0-9\]+, w\[0-9\]" 0 } } */ +/* { dg-final { scan-assembler-times "ldp\tx\[0-9\]+, x\[0-9\]" 0 } } */ +/* { dg-final { scan-assembler-times "ldp\tq\[0-9\]+, q\[0-9\]" 0 } } */ + diff --git a/gcc/testsuite/gcc.target/aarch64/stp_aligned.c b/gcc/testsuite/gcc.target/aarch64/stp_aligned.c index ab9c2f42dd3..20bd95373fa 100644 --- a/gcc/testsuite/gcc.target/aarch64/stp_aligned.c +++ b/gcc/testsuite/gcc.target/aarch64/stp_aligned.c @@ -13,15 +13,6 @@ TYPE *stp_aligned_##TYPE(char* ptr, TYPE x){ \ return arr; \ } -#define STP_TEST_UNALIGNED(TYPE) \ -TYPE *stp_unaligned_##TYPE(char* ptr, TYPE x){ \ - TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ - TYPE *a = arr+1; \ - a[0] = x; \ - a[1] = x; \ - return a; \ -} - #define STP_TEST_ADJUST_ALIGNED(TYPE) \ TYPE *stp_aligned_adjust_##TYPE(char* ptr, TYPE x){ \ TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ @@ -32,27 +23,11 @@ TYPE *stp_aligned_adjust_##TYPE(char* ptr, TYPE x){ \ return arr; \ } -#define STP_TEST_ADJUST_UNALIGNED(TYPE) \ -TYPE *stp_unaligned_adjust_##TYPE(char* ptr, TYPE x){ \ - TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ - TYPE *a = arr+1; \ - a[100] = x; \ - a[101] = x; \ - a[102] = x; \ - a[103] = x; \ - return a; \ -} - STP_TEST_ALIGNED(int32_t); STP_TEST_ALIGNED(int64_t); STP_TEST_ALIGNED(v4si); -STP_TEST_UNALIGNED(int32_t); -STP_TEST_UNALIGNED(int64_t); -STP_TEST_UNALIGNED(v4si); STP_TEST_ADJUST_ALIGNED(int32_t); STP_TEST_ADJUST_ALIGNED(int64_t); -STP_TEST_ADJUST_UNALIGNED(int32_t); -STP_TEST_ADJUST_UNALIGNED(int64_t); /* { dg-final { scan-assembler-times "stp\tw\[0-9\]+, w\[0-9\]" 3 } } */ /* { dg-final { scan-assembler-times "stp\tx\[0-9\]+, x\[0-9\]" 3 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/stp_unaligned.c b/gcc/testsuite/gcc.target/aarch64/stp_unaligned.c new file mode 100644 index 00000000000..9a5690af362 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/stp_unaligned.c @@ -0,0 +1,37 @@ +/* { dg-options "-O2 --param=aarch64-stp-policy=aligned -mcpu=generic" } */ + +#include <stdlib.h> +#include <stdint.h> + +typedef int v4si __attribute__ ((vector_size (16))); + +#define STP_TEST_UNALIGNED(TYPE) \ +TYPE *stp_unaligned_##TYPE(char* ptr, TYPE x){ \ + TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ + TYPE *a = arr+1; \ + a[0] = x; \ + a[1] = x; \ + return a; \ +} + +#define STP_TEST_ADJUST_UNALIGNED(TYPE) \ +TYPE *stp_unaligned_adjust_##TYPE(char* ptr, TYPE x){ \ + TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ + TYPE *a = arr+1; \ + a[100] = x; \ + a[101] = x; \ + a[102] = x; \ + a[103] = x; \ + return a; \ +} + +STP_TEST_UNALIGNED(int32_t); +STP_TEST_UNALIGNED(int64_t); +STP_TEST_UNALIGNED(v4si); +STP_TEST_ADJUST_UNALIGNED(int32_t); +STP_TEST_ADJUST_UNALIGNED(int64_t); + +/* { dg-final { scan-assembler-times "stp\tw\[0-9\]+, w\[0-9\]" 0 } } */ +/* { dg-final { scan-assembler-times "stp\tx\[0-9\]+, x\[0-9\]" 0 } } */ +/* { dg-final { scan-assembler-times "stp\tq\[0-9\]+, q\[0-9\]" 0 } } */ + -- 2.40.1