]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Fix -march=native when -mtune is used [PR124629] master trunk
authorAlice Carlotti <alice.carlotti@arm.com>
Fri, 7 Aug 2026 16:56:49 +0000 (17:56 +0100)
committerAlice Carlotti <alice.carlotti@arm.com>
Mon, 10 Aug 2026 10:28:14 +0000 (11:28 +0100)
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.

gcc/config/aarch64/driver-aarch64.cc
gcc/testsuite/gcc.target/aarch64/cpunative/info_36 [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_36.c [new file with mode: 0644]

index 278f26c92194801739c57862de097a3093487de2..7433ba90267c0764760c1bdeeae80f1b247b1f3a 100644 (file)
@@ -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 (file)
index 0000000..620340f
--- /dev/null
@@ -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 (file)
index 0000000..04af5b0
--- /dev/null
@@ -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} } } */