Hi All, in g:e91a17fe39c39e98cebe6e1cbc8064ee6846a3a7 we added the ability for -mcpu=native on unknown CPUs to still enable architecture extensions.
This has worked great but was only added for homogenous systems. However the same thing works for big.LITTLE as in such system the cores must have the same extensions otherwise it doesn't fundamentally work. i.e. task migration from one core to the other wouldn't work. This extends the same handling to non-homogenous systems. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for master? Thanks, Tamar gcc/ChangeLog: PR target/113257 * config/aarch64/driver-aarch64.cc (host_detect_local_cpu): gcc/testsuite/ChangeLog: PR target/113257 * gcc.target/aarch64/cpunative/info_34: New test. * gcc.target/aarch64/cpunative/native_cpu_34.c: New test. --- diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc index 45fce67a646351b848b7cd7d0fd35d343731c0d1..2a454daf031aa3ac81a9a2c03b15c09731e4f56e 100644 --- a/gcc/config/aarch64/driver-aarch64.cc +++ b/gcc/config/aarch64/driver-aarch64.cc @@ -449,6 +449,20 @@ host_detect_local_cpu (int argc, const char **argv) break; } } + + /* 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) + { + auto arch_info = get_arch_from_id (DEFAULT_ARCH); + + gcc_assert (arch_info); + + res = concat ("-march=", arch_info->name, NULL); + default_flags = arch_info->flags; + } + if (!res) goto not_found; } diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_34 b/gcc/testsuite/gcc.target/aarch64/cpunative/info_34 new file mode 100644 index 0000000000000000000000000000000000000000..61cb254785a4b9ec19ebe388402223c9a82af7ed --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_34 @@ -0,0 +1,18 @@ +processor : 0 +BogoMIPS : 100.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp sve sve2 fphp asimdhp fcma +CPU implementer : 0xfe +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 2 + +processor : 0 +BogoMIPS : 100.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp sve sve2 fphp asimdhp fcma +CPU implementer : 0xfe +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd09 +CPU revision : 2 + diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c new file mode 100644 index 0000000000000000000000000000000000000000..168140002a0f0205c0f552de0cce9b2d356e09e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */ +/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_34" } */ +/* { dg-additional-options "-mcpu=native" } */ + +int main() +{ + return 0; +} + +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+sve2\n} } } */ + +/* Test a normal looking procinfo. */ --
diff --git a/gcc/config/aarch64/driver-aarch64.cc b/gcc/config/aarch64/driver-aarch64.cc index 45fce67a646351b848b7cd7d0fd35d343731c0d1..2a454daf031aa3ac81a9a2c03b15c09731e4f56e 100644 --- a/gcc/config/aarch64/driver-aarch64.cc +++ b/gcc/config/aarch64/driver-aarch64.cc @@ -449,6 +449,20 @@ host_detect_local_cpu (int argc, const char **argv) break; } } + + /* 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) + { + auto arch_info = get_arch_from_id (DEFAULT_ARCH); + + gcc_assert (arch_info); + + res = concat ("-march=", arch_info->name, NULL); + default_flags = arch_info->flags; + } + if (!res) goto not_found; } diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_34 b/gcc/testsuite/gcc.target/aarch64/cpunative/info_34 new file mode 100644 index 0000000000000000000000000000000000000000..61cb254785a4b9ec19ebe388402223c9a82af7ed --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_34 @@ -0,0 +1,18 @@ +processor : 0 +BogoMIPS : 100.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp sve sve2 fphp asimdhp fcma +CPU implementer : 0xfe +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd08 +CPU revision : 2 + +processor : 0 +BogoMIPS : 100.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 asimddp sve sve2 fphp asimdhp fcma +CPU implementer : 0xfe +CPU architecture: 8 +CPU variant : 0x0 +CPU part : 0xd09 +CPU revision : 2 + diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c new file mode 100644 index 0000000000000000000000000000000000000000..168140002a0f0205c0f552de0cce9b2d356e09e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_34.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */ +/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_34" } */ +/* { dg-additional-options "-mcpu=native" } */ + +int main() +{ + return 0; +} + +/* { dg-final { scan-assembler {\.arch armv8-a\+dotprod\+crc\+crypto\+sve2\n} } } */ + +/* Test a normal looking procinfo. */