@@ -494,6 +494,10 @@ NO_INLINE static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_i
494
494
features -> fTSCINV_BIT = 1 ;
495
495
if (_cpuid_info -> std_cpuid1_ecx .bits .aes != 0 )
496
496
features -> fAES = 1 ;
497
+ if (_cpuid_info -> ext_cpuid1_ecx .bits .lzcnt != 0 )
498
+ features -> fLZCNT = 1 ;
499
+ if (_cpuid_info -> ext_cpuid1_ecx .bits .prefetchw != 0 )
500
+ features -> fAMD_3DNOW_PREFETCH = 1 ;
497
501
if (_cpuid_info -> sef_cpuid7_ebx .bits .erms != 0 )
498
502
features -> fERMS = 1 ;
499
503
if (_cpuid_info -> sef_cpuid7_edx .bits .fast_short_rep_mov != 0 )
@@ -512,6 +516,8 @@ NO_INLINE static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_i
512
516
features -> fFMA = 1 ;
513
517
if (_cpuid_info -> sef_cpuid7_ebx .bits .clflushopt != 0 )
514
518
features -> fFLUSHOPT = 1 ;
519
+ if (_cpuid_info -> sef_cpuid7_ebx .bits .clwb != 0 )
520
+ features -> fCLWB = 1 ;
515
521
if (_cpuid_info -> ext_cpuid1_edx .bits .rdtscp != 0 )
516
522
features -> fRDTSCP = 1 ;
517
523
if (_cpuid_info -> sef_cpuid7_ecx .bits .rdpid != 0 )
@@ -520,47 +526,31 @@ NO_INLINE static void set_cpufeatures(CPUFeatures *features, CpuidInfo *_cpuid_i
520
526
_cpuid_info -> xem_xcr0_eax .bits .apx_f != 0 )
521
527
features -> fAPX_F = 1 ;
522
528
523
- // AMD|Hygon features.
529
+ // AMD|Hygon additional features.
524
530
if (is_amd_family (_cpuid_info ))
525
531
{
526
- if (( _cpuid_info -> ext_cpuid1_edx . bits . tdnow != 0 ) ||
527
- (_cpuid_info -> ext_cpuid1_ecx .bits .prefetchw != 0 ) )
532
+ // PREFETCHW was checked above, check TDNOW here.
533
+ if (_cpuid_info -> ext_cpuid1_edx .bits .tdnow != 0 )
528
534
features -> fAMD_3DNOW_PREFETCH = 1 ;
529
- if (_cpuid_info -> ext_cpuid1_ecx .bits .lzcnt != 0 )
530
- features -> fLZCNT = 1 ;
531
535
if (_cpuid_info -> ext_cpuid1_ecx .bits .sse4a != 0 )
532
536
features -> fSSE4A = 1 ;
533
537
}
534
538
535
- // Intel features.
539
+ // Intel additional features.
536
540
if (is_intel (_cpuid_info ))
537
541
{
538
- if (_cpuid_info -> ext_cpuid1_ecx .bits .lzcnt != 0 ) {
539
- features -> fLZCNT = 1 ;
540
- }
541
- if (_cpuid_info -> ext_cpuid1_ecx .bits .prefetchw != 0 ) {
542
- features -> fAMD_3DNOW_PREFETCH = 1 ;
543
- }
544
- if (_cpuid_info -> sef_cpuid7_ebx .bits .clwb != 0 ) {
545
- features -> fCLWB = 1 ;
546
- }
547
- if (_cpuid_info -> sef_cpuid7_edx .bits .serialize != 0 ) {
542
+ if (_cpuid_info -> sef_cpuid7_edx .bits .serialize != 0 )
548
543
features -> fSERIALIZE = 1 ;
549
- }
550
- if (_cpuid_info -> sef_cpuid7_edx .bits .avx512_fp16 != 0 ) {
544
+ if (_cpuid_info -> sef_cpuid7_edx .bits .avx512_fp16 != 0 )
551
545
features -> fAVX512_FP16 = 1 ;
552
- }
553
546
}
554
547
555
- // ZX features.
548
+ // ZX additional features.
556
549
if (is_zx (_cpuid_info ))
557
550
{
558
- if (_cpuid_info -> ext_cpuid1_ecx .bits .lzcnt != 0 ) {
559
- features -> fLZCNT = 1 ;
560
- }
561
- if (_cpuid_info -> ext_cpuid1_ecx .bits .prefetchw != 0 ) {
562
- features -> fAMD_3DNOW_PREFETCH = 1 ;
563
- }
551
+ // We do not know if these are supported by ZX, so we cannot trust
552
+ // common CPUID bit for them.
553
+ features -> fCLWB = 0 ;
564
554
}
565
555
566
556
// Protection key features.
0 commit comments