-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing an issue with the CPUID check for BMI1/BMI2 and LZCNT #40615
Conversation
CC. @jkotas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
|
||
if (maxCpuIdEx >= 0x80000001) | ||
{ | ||
__cpuid(cpuidInfo, 0x80000001); | ||
|
||
if ((cpuidInfo[3] & (1 << 5)) != 0) // LZCNT | ||
if ((cpuidInfo[ECX] & (1 << 5)) != 0) // LZCNT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit description only mentions changes for BMI1/2.
Is this change from 3 to ECX=2 for LZCNT intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, spotted the comment
// LZCNT - ECX bit 5
on line 1351
#40167 redid part of the CPUID logic as part of exposing X86Base.CpuId. As part of that, the check for BMI1/2 was updated to use an incorrect index.
This fixes the logic to use 4 named constants during lookup to help avoid this issue.