util: move check for AVX512

As a side effect solve:
```
[91/1401] Compiling C object src/util/libmesa_util.a.p/u_cpu_detect.c.o
../src/util/u_cpu_detect.c: In function '_util_cpu_detect_once':
../src/util/u_cpu_detect.c:889:11: warning: 'regs2[2]' may be used uninitialized [-Wmaybe-uninitialized]
  889 |       if (((regs2[2] >> 27) & 1) && // OSXSAVE
      |           ^~~~~~~~~~~~~~~~~~~~~~
../src/util/u_cpu_detect.c:823:16: note: 'regs2[2]' was declared here
  823 |       uint32_t regs2[4];
      |                ^~~~~
```

Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23164>
This commit is contained in:
Ryan Houdek 2023-05-22 22:58:56 +02:00 committed by Marge Bot
parent ca856143d4
commit a7f623e099

View file

@ -883,23 +883,19 @@ _util_cpu_detect_once(void)
uint32_t regs7[4];
cpuid_count(0x00000007, 0x00000000, regs7);
util_cpu_caps.has_avx2 = (regs7[1] >> 5) & 1;
}
// check for avx512
if (((regs2[2] >> 27) & 1) && // OSXSAVE
(xgetbv() & (0x7 << 5)) && // OPMASK: upper-256 enabled by OS
((xgetbv() & 6) == 6)) { // XMM/YMM enabled by OS
uint32_t regs3[4];
cpuid_count(0x00000007, 0x00000000, regs3);
util_cpu_caps.has_avx512f = (regs3[1] >> 16) & 1;
util_cpu_caps.has_avx512dq = (regs3[1] >> 17) & 1;
util_cpu_caps.has_avx512ifma = (regs3[1] >> 21) & 1;
util_cpu_caps.has_avx512pf = (regs3[1] >> 26) & 1;
util_cpu_caps.has_avx512er = (regs3[1] >> 27) & 1;
util_cpu_caps.has_avx512cd = (regs3[1] >> 28) & 1;
util_cpu_caps.has_avx512bw = (regs3[1] >> 30) & 1;
util_cpu_caps.has_avx512vl = (regs3[1] >> 31) & 1;
util_cpu_caps.has_avx512vbmi = (regs3[2] >> 1) & 1;
// check for avx512
if (xgetbv() & (0x7 << 5)) { // OPMASK: upper-256 enabled by OS
util_cpu_caps.has_avx512f = (regs7[1] >> 16) & 1;
util_cpu_caps.has_avx512dq = (regs7[1] >> 17) & 1;
util_cpu_caps.has_avx512ifma = (regs7[1] >> 21) & 1;
util_cpu_caps.has_avx512pf = (regs7[1] >> 26) & 1;
util_cpu_caps.has_avx512er = (regs7[1] >> 27) & 1;
util_cpu_caps.has_avx512cd = (regs7[1] >> 28) & 1;
util_cpu_caps.has_avx512bw = (regs7[1] >> 30) & 1;
util_cpu_caps.has_avx512vl = (regs7[1] >> 31) & 1;
util_cpu_caps.has_avx512vbmi = (regs7[2] >> 1) & 1;
}
}
if (regs[1] == 0x756e6547 && regs[2] == 0x6c65746e && regs[3] == 0x49656e69) {