Richard Sandiford <richard.sandif...@arm.com> writes:
> Tamar Christina <tamar.christ...@arm.com> writes:
>> Ok for master? and how do you feel about a backport for the two patches to 
>> help
>> distros?
>
> Backporting to GCC 14 & GCC 13 sounds good.  Not so sure about GCC 12,
> since I think we should be extra cautious with the "most stable" branch,
> but let's see what others think.
>
> OK for trunk, and for GCC 14 & 13 after a grace period, with one
> trivial nit below:

Sorry, was concentrating too much on the -mcpu vs. -march preemption
thing and forgot to think about other aspects of the patch.  The routine
is used for all three of -march=native, -mcpu=native, and -mtune=native,
so I think we want something like the following on top of your patch
(untested so far).

Richard


diff --git a/gcc/config/aarch64/driver-aarch64.cc 
b/gcc/config/aarch64/driver-aarch64.cc
index 731b5e48687..26ba2cd6f88 100644
--- a/gcc/config/aarch64/driver-aarch64.cc
+++ b/gcc/config/aarch64/driver-aarch64.cc
@@ -419,18 +419,11 @@ host_detect_local_cpu (int argc, const char **argv)
                 || variants[0] == aarch64_cpu_data[i].variant))
          break;
 
-      if (aarch64_cpu_data[i].name == NULL)
+      if (arch)
        {
-         auto cpu_info = get_cpu_from_id (DEFAULT_CPU);
-
-         gcc_assert (cpu_info);
-
-         res = concat ("-mcpu=", cpu_info->name, NULL);
-         default_flags = cpu_info->flags;
-       }
-      else if (arch)
-       {
-         const char *arch_id = aarch64_cpu_data[i].arch;
+         const char *arch_id = (aarch64_cpu_data[i].name
+                                ? aarch64_cpu_data[i].arch
+                                : DEFAULT_ARCH);
          auto arch_info = get_arch_from_id (arch_id);
 
          /* We got some arch indentifier that's not in aarch64-arches.def?  */
@@ -440,12 +433,15 @@ host_detect_local_cpu (int argc, const char **argv)
          res = concat ("-march=", arch_info->name, NULL);
          default_flags = arch_info->flags;
        }
-      else
+      else if (cpu || aarch64_cpu_data[i].name)
        {
-         default_flags = aarch64_cpu_data[i].flags;
+         auto cpu_info = (aarch64_cpu_data[i].name
+                          ? &aarch64_cpu_data[i]
+                          : get_cpu_from_id (DEFAULT_CPU));
+         default_flags = cpu_info->flags;
          res = concat ("-m",
                        cpu ? "cpu" : "tune", "=",
-                       aarch64_cpu_data[i].name,
+                       cpu_info->name,
                        NULL);
        }
     }
@@ -469,7 +465,7 @@ host_detect_local_cpu (int argc, const char **argv)
       /* On big.LITTLE if we find any unknown CPUs we can still pick arch
         features as the cores should have the same features.  So just pick
         the feature flags from any of the cpus.  */
-      if (aarch64_cpu_data[i].name == NULL)
+      if (cpu && aarch64_cpu_data[i].name == NULL)
        {
          auto cpu_info = get_cpu_from_id (DEFAULT_CPU);
 

Reply via email to