]> git.ipfire.org Git - thirdparty/gcc.git/commit
fmv: Redirect to specific target
authorAlfie Richards <alfie.richards@arm.com>
Mon, 14 Apr 2025 14:11:29 +0000 (14:11 +0000)
committerAlfie Richards <alfie.richards@arm.com>
Tue, 30 Sep 2025 19:27:21 +0000 (19:27 +0000)
commit3ea8d691e889945dfa12d50d7fa232e6286506d1
tree746aa0f5561f0a3ad3dbb18f97edf359dce36207
parent6e624833cbe0a7479564fbe3294e10c9d4746a2e
fmv: Redirect to specific target

Adds an optimisation in FMV to redirect to a specific target if possible.

A call is redirected to a specific target if both:
- the caller can always call the callee version
- and, it is possible to rule out all higher priority versions of the callee
  fmv set. That is estabilished either by the callee being the highest priority
  version, or each higher priority version of the callee implying that, were it
  resolved, a higher priority version of the caller would have been selected.

For this logic, introduces the new TARGET_OPTION_FUNCTIONS_B_RESOLVABLE_FROM_A
hook. Adds a full implementation for Aarch64, and a weaker default version
for other targets.

This allows the target to replace the previous optimisation as the new one is
able to cover the same case where two function sets implement the same versions.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_functions_b_resolvable_from_a): New
function.
(TARGET_OPTION_FUNCTIONS_B_RESOLVABLE_FROM_A): New define.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add documentation for
TARGET_OPTION_FUNCTIONS_B_RESOLVABLE_FROM_A.
* multiple_target.cc (redirect_to_specific_clone): Add new optimisation
logic.
(ipa_target_clone): Remove check for TARGET_HAS_FMV_TARGET_ATTRIBUTE.
* target.def: Document new hook..
* attribs.cc: (functions_b_resolvable_from_a) New function.
* attribs.h: (functions_b_resolvable_from_a) New function.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/fmv-selection1.C: New test.
* g++.target/aarch64/fmv-selection2.C: New test.
* g++.target/aarch64/fmv-selection3.C: New test.
* g++.target/aarch64/fmv-selection4.C: New test.
* g++.target/aarch64/fmv-selection5.C: New test.
* g++.target/aarch64/fmv-selection6.C: New test.
* g++.target/aarch64/fmv-selection7.C: New test.
14 files changed:
gcc/attribs.cc
gcc/attribs.h
gcc/config/aarch64/aarch64.cc
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/multiple_target.cc
gcc/target.def
gcc/testsuite/g++.target/aarch64/fmv-selection1.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/fmv-selection2.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/fmv-selection3.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/fmv-selection4.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/fmv-selection5.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/fmv-selection6.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/fmv-selection7.C [new file with mode: 0644]