This is an archive of the discontinued LLVM Phabricator instance.

[X86] Workaround possible CPUID bug in Sandy Bridge.
ClosedPublic

Authored by craig.topper on Aug 2 2023, 9:22 PM.

Details

Summary

Don't access leaf 7 subleaf 1 unless subleaf 0 says it is
supported via EAX.

Intel documentation says invalid subleaves return 0. We had been
relying on that behavior instead of checking the max sublef number.

It appears that some Sandy Bridge CPUs return at least the subleaf 0
EDX value for subleaf 1. Best guess is that this is a bug in a
microcode patch since all of the bits we're seeing set in EDX were
introduced after Sandy Bridge was originally released.

This is causing avxvnniint16 to be incorrectly enabled with -march=native
on these CPUs.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 2 2023, 9:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 9:22 PM
craig.topper requested review of this revision.Aug 2 2023, 9:22 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 2 2023, 9:22 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Fix another subleaf 1 access

pengfei accepted this revision.Aug 2 2023, 10:02 PM

LGTM, thanks!

This revision is now accepted and ready to land.Aug 2 2023, 10:02 PM

Does this need to backport to llvm 17?

anna added a comment.EditedAug 3 2023, 7:09 AM

thank you for the fix! Details of the diagnostic is here (for reference later) : https://reviews.llvm.org/D155145#4556178

anna accepted this revision.Aug 3 2023, 7:10 AM
This revision was automatically updated to reflect the committed changes.