aom: aarch64_cpudetect.c: Don't read AT_HWCAPs if they are not needed

From 2036fbe2d8449c1054b4fb8bdf22c78f92655afc Mon Sep 17 00:00:00 2001
From: George Steed <[EMAIL REDACTED]>
Date: Wed, 7 Feb 2024 15:38:54 +0000
Subject: [PATCH] aarch64_cpudetect.c: Don't read AT_HWCAPs if they are not
 needed

If FEAT_I8MM is not supported by the compiler then we do not test the
value from getauxval(AT_HWCAP2), leading to an unused variable warning.

To suppress this, only read the variable if we are going to use it,
which for now is only to check FEAT_I8MM. Also do similarly for AT_HWCAP
to match.

Bug: aomedia:3543
Change-Id: I855c255105cbfc448f64df317507dd9184731479
---
 aom_ports/aarch64_cpudetect.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/aom_ports/aarch64_cpudetect.c b/aom_ports/aarch64_cpudetect.c
index 43d5a149c8..13299a688e 100644
--- a/aom_ports/aarch64_cpudetect.c
+++ b/aom_ports/aarch64_cpudetect.c
@@ -108,8 +108,13 @@ static int arm_get_cpu_caps(void) {
 
 static int arm_get_cpu_caps(void) {
   int flags = 0;
+#if HAVE_ARM_CRC32 || HAVE_NEON_DOTPROD || HAVE_SVE
   unsigned long hwcap = getauxval(AT_HWCAP);
+#endif
+#if HAVE_NEON_I8MM
   unsigned long hwcap2 = getauxval(AT_HWCAP2);
+#endif
+
 #if HAVE_NEON
   flags |= HAS_NEON;  // Neon is mandatory in Armv8.0-A.
 #endif  // HAVE_NEON