RE: [PATCH] aarch64: Fix -march=native when -mtune is used [PR124629]

Tamar Christina <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <VI0PR08MB10392BA9198412CE98DD5AA18FFDE2@VI0PR08MB10392.eurprd08.prod.outlook.com>
> -----Original Message-----
> From: Alice Carlotti <[email protected]>
> Sent: 07 August 2026 18:19
> To: [email protected]
> Cc: Richard Earnshaw <[email protected]>; Tamar Christina
> <[email protected]>; Kyrylo Tkachov <[email protected]>; Alex
> Coplan <[email protected]>; Andrew Pinski
> <[email protected]>; Wilco Dijkstra
> <[email protected]>; Cutie Deng <[email protected]>
> Subject: [PATCH] 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.
> 
> 
> This is the alternative fix I suggested in my review of Cutie Deng's patch [1],
> with an added test case.
> 
> Ok for master and backport to all open branches?

OK with a minor nit below.  OK for branches too but give it some time on trunk.

> 
> [1] https://gcc.gnu.org/pipermail/gcc-patches/2026-March/711748.html
> 
> 
> 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 --git a/gcc/config/aarch64/driver-aarch64.cc
> b/gcc/config/aarch64/driver-aarch64.cc
> index
> 278f26c92194801739c57862de097a3093487de2..300cdceca63c3c984406
> 37258bd85a212b300952 100644
> --- a/gcc/config/aarch64/driver-aarch64.cc
> +++ b/gcc/config/aarch64/driver-aarch64.cc
> @@ -81,7 +81,7 @@ struct aarch64_arch_driver_info
> 
>  /* Skip the leading "V" in the architecture name.  */

This comment is no longer accurate.

Thanks,
Tamar

>  #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
> 0000000000000000000000000000000000000000..620340fdfaeb8d0bdf9
> 43a5563603bc04ab88ce4
> --- /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
> 0000000000000000000000000000000000000000..04af5b04ba5f9c2193f
> d4725ad3aa67d185461ea
> --- /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} } } */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.