Skip to content

Commit

Permalink
Fix bugs in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Jan 24, 2025
1 parent f6622ac commit 2710281
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/arch/intel/asm/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ uint64_t aws_run_xgetbv(uint32_t xcr) {
/* NOTE: we could have used the _xgetbv() intrinsic in <immintrin.h>, but it's missing from GCC < 9.0:
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71659 */

/* xgetbv writes high and low of 64bit value to EAX:EDX */
uint32_t eax;
uint32_t edx;
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr));
return (((uint64_t)eax) << 32) | edx;
/* xgetbv writes high and low of 64bit value to EDX:EAX */
uint32_t xcrhigh;
uint32_t xcrlow;
__asm__ __volatile__("xgetbv" : "=a"(xcrlow), "=d"(xcrhigh) : "c"(xcr));
return (((uint64_t)xcrhigh) << 32) | xcrlow;
}
3 changes: 3 additions & 0 deletions source/arch/intel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ static void s_cache_cpu_features(void) {
* We don't know for sure what was up with those machines, but this extra
* check should stop them from running our AVX/AVX2 code paths. */
if (feature_avx) {
if (avx_usable) {
s_cpu_features[AWS_CPU_FEATURE_AVX2] = abcd[1] & (1 << 5); /* AVX2 = EBX[bit 5] */
}
if (avx512_usable) {
s_cpu_features[AWS_CPU_FEATURE_AVX512] = abcd[1] & (1 << 16); /* AVX-512 Foundation = EBX[bit 16] */
}
Expand Down

0 comments on commit 2710281

Please sign in to comment.