]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/config/aarch64/aarch64.opt
aarch64: Fine-grained policies to control ldp-stp formation
authorManos Anagnostakis <manos.anagnostakis@vrull.eu>
Tue, 26 Sep 2023 05:02:02 +0000 (07:02 +0200)
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>
Wed, 27 Sep 2023 13:13:37 +0000 (15:13 +0200)
commit834fc2bf05537ff19c5c1e7bd041d7e89eb450ed
tree3e1b534ffdd699b4f09c70ea0c872153f09a4e5b
parentb31218bc93683554077c68dec14f4217a5e66835
aarch64: Fine-grained policies to control ldp-stp formation

This patch implements the following TODO in gcc/config/aarch64/aarch64.cc
to provide the requested behaviour for handling ldp and stp:

  /* Allow the tuning structure to disable LDP instruction formation
     from combining instructions (e.g., in peephole2).
     TODO: Implement fine-grained tuning control for LDP and STP:
           1. control policies for load and store separately;
           2. support the following policies:
              - default (use what is in the tuning structure)
              - always
              - never
              - aligned (only if the compiler can prove that the
                load will be aligned to 2 * element_size)  */

It provides two new and concrete target-specific command-line parameters
--param=aarch64-ldp-policy= and --param=aarch64-stp-policy=
to give the ability to control load and store policies seperately as
stated in part 1 of the TODO.

The accepted values for both parameters are:
 * default: Use the policy of the tuning structure (default).
 * always: Emit ldp/stp regardless of alignment.
 * never: Do not emit ldp/stp.
 * aligned: In order to emit ldp/stp, first check if the load/store will
   be aligned to 2 * element_size.

Bootstrapped and regtested aarch64-linux.

gcc/ChangeLog:
* config/aarch64/aarch64-opts.h (enum aarch64_ldp_policy): New
enum type.
(enum aarch64_stp_policy): New enum type.
* config/aarch64/aarch64-protos.h (struct tune_params): Add
appropriate enums for the policies.
(aarch64_mem_ok_with_ldpstp_policy_model): New declaration.
* config/aarch64/aarch64-tuning-flags.def
(AARCH64_EXTRA_TUNING_OPTION): Remove superseded tuning
options.
* config/aarch64/aarch64.cc (aarch64_parse_ldp_policy): New
function to parse ldp-policy parameter.
(aarch64_parse_stp_policy): New function to parse stp-policy parameter.
(aarch64_override_options_internal): Call parsing functions.
(aarch64_mem_ok_with_ldpstp_policy_model): New function.
(aarch64_operands_ok_for_ldpstp): Add call to
aarch64_mem_ok_with_ldpstp_policy_model for parameter-value
check and alignment check and remove superseded ones.
(aarch64_operands_adjust_ok_for_ldpstp): Add call to
aarch64_mem_ok_with_ldpstp_policy_model for parameter-value
check and alignment check and remove superseded ones.
* config/aarch64/aarch64.opt (aarch64-ldp-policy): New param.
(aarch64-stp-policy): New param.
* doc/invoke.texi: Document the parameters accordingly.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/ampere1-no_ldp_combine.c: Removed.
* gcc.target/aarch64/ldp_aligned.c: New test.
* gcc.target/aarch64/ldp_always.c: New test.
* gcc.target/aarch64/ldp_never.c: New test.
* gcc.target/aarch64/stp_aligned.c: New test.
* gcc.target/aarch64/stp_always.c: New test.
* gcc.target/aarch64/stp_never.c: New test.

Signed-off-by: Manos Anagnostakis <manos.anagnostakis@vrull.eu>
Co-Authored-By: Philipp Tomsich <philipp.tomsich@vrull.eu>
Co-Authored-By: Manolis Tsamis <manolis.tsamis@vrull.eu>
13 files changed:
gcc/config/aarch64/aarch64-opts.h
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64-tuning-flags.def
gcc/config/aarch64/aarch64.cc
gcc/config/aarch64/aarch64.opt
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/aarch64/ampere1-no_ldp_combine.c [deleted file]
gcc/testsuite/gcc.target/aarch64/ldp_aligned.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/ldp_always.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/ldp_never.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/stp_aligned.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/stp_always.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/stp_never.c [new file with mode: 0644]