https://gcc.gnu.org/g:f1837613162b4aed08a47efba875616e19f4362a
commit r16-4578-gf1837613162b4aed08a47efba875616e19f4362a Author: Alfie Richards <[email protected]> Date: Tue Oct 7 12:04:14 2025 +0000 aarch64: Fix fmv priority ordering [PR target/122190] This fixes the versioning rules for aarch64. Previously this would prioritize the version string with more extensions specified regardless of the extension. The ACLE rules are that any two version strings should be ordered by the highest priority feature that the versions don't have in common. PR target/122190 gcc/ChangeLog: * config/aarch64/aarch64.cc (compare_feature_masks): Fix version rules. gcc/testsuite/ChangeLog: * gcc.target/aarch64/pr122190.c: New test Reviewed-by: Wilco Dijkstra <[email protected]> Diff: --- gcc/config/aarch64/aarch64.cc | 8 +------- gcc/testsuite/gcc.target/aarch64/pr122190.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index bb3a10bb610f..a0da08e3bd53 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -20607,14 +20607,8 @@ static int compare_feature_masks (aarch64_fmv_feature_mask mask1, aarch64_fmv_feature_mask mask2) { - int pop1 = popcount_hwi (mask1); - int pop2 = popcount_hwi (mask2); - if (pop1 > pop2) - return 1; - if (pop2 > pop1) - return -1; - auto diff_mask = mask1 ^ mask2; + /* If there is no difference. */ if (diff_mask == 0ULL) return 0; int num_features = ARRAY_SIZE (aarch64_fmv_feature_data); diff --git a/gcc/testsuite/gcc.target/aarch64/pr122190.c b/gcc/testsuite/gcc.target/aarch64/pr122190.c new file mode 100644 index 000000000000..8546e1200634 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr122190.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=armv8-a -fdump-ipa-targetclone1-details" } */ + +int fn (int a) {return 1;} +int fn[[gnu::target_version("sve")]] (int a) {return 2;} +int fn[[gnu::target_version("simd+dotprod")]] (int a) {return 3;} +int fn[[gnu::target_version("sve+fp")]] (int a) {return 2;} + +/* { dg-final { scan-ipa-dump-times "Version order for fn/\[0-9\]+:\\nfn\.default/\[0-9\]+\\nfn\._MsimdMdotprod/\[0-9\]+\\nfn\._Msve/\[0-9\]+\\nfn\._MfpMsve/\[0-9\]+\\n" 1 "targetclone1" } } */
