https://gcc.gnu.org/g:b41352c7aa2645de6c5751d447589c2ef8c4fa4d

commit r17-3185-gb41352c7aa2645de6c5751d447589c2ef8c4fa4d
Author: Alice Carlotti <[email protected]>
Date:   Fri Aug 7 17:56:49 2026 +0100

    aarch64: Fix -march=native when -mtune is used [PR124629]
    
    Handling of -march=native for recognised cores was broken by
    r13-2937-g00c22ba69d8e73, which added "V" to ARCH_IDENT values and
    filtered it out in some locations.  This causes a lookup by stringified
    ARCH_IDENT values to fail.  If no -mtune or -mcpu option is used, then
    we avoid this bug by upgrading -march=native to -mcpu=native.
    
    Fix this by removing the '+ 1' string offset, so that the ident strings
    match again.  It would be marginally more efficient to use enum values
    here, but I've stuck with this simpler fix instead.
    
    gcc/ChangeLog:
    
            PR target/124629
            * config/aarch64/driver-aarch64.cc (AARCH64_ARCH):
            Don't skip first character of #ARCH_IDENT.
    
    gcc/testsuite/ChangeLog:
    
            PR target/124629
            * gcc.target/aarch64/cpunative/info_36: New test file.
            * gcc.target/aarch64/cpunative/native_cpu_36.c: New test.

Diff:
---
 gcc/config/aarch64/driver-aarch64.cc                       |  3 +--
 gcc/testsuite/gcc.target/aarch64/cpunative/info_36         |  9 +++++++++
 gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_36.c | 10 ++++++++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/driver-aarch64.cc 
b/gcc/config/aarch64/driver-aarch64.cc
index 278f26c92194..7433ba90267c 100644
--- a/gcc/config/aarch64/driver-aarch64.cc
+++ b/gcc/config/aarch64/driver-aarch64.cc
@@ -79,9 +79,8 @@ struct aarch64_arch_driver_info
   aarch64_feature_flags flags;
 };
 
-/* Skip the leading "V" in the architecture name.  */
 #define AARCH64_ARCH(NAME, CORE, ARCH_IDENT, ARCH_REV, FLAGS) \
-  { #ARCH_IDENT + 1, NAME, feature_deps::ARCH_IDENT ().enable },
+  { #ARCH_IDENT, NAME, feature_deps::ARCH_IDENT ().enable },
 
 static constexpr const aarch64_arch_driver_info aarch64_arches[] =
 {
diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_36 
b/gcc/testsuite/gcc.target/aarch64/cpunative/info_36
new file mode 100644
index 000000000000..620340fdfaeb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_36
@@ -0,0 +1,9 @@
+processor      : 0
+BogoMIPS       : 100.00
+Features       : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp sve sve2 
fphp asimdhp fcma
+CPU implementer        : 0x41
+CPU architecture: 8
+CPU variant    : 0x0
+CPU part       : 0xd08
+CPU revision   : 2
+
diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_36.c 
b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_36.c
new file mode 100644
index 000000000000..04af5b04ba5f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_36.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */
+/* { dg-set-compiler-env-var GCC_CPUINFO 
"$srcdir/gcc.target/aarch64/cpunative/info_36" } */
+/* { dg-additional-options "-march=native -mtune=cortex-a34" } */
+
+int main()
+{
+  return 0;
+}
+
+/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+sve2\n} 
} } */

Reply via email to