File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,20 @@ fn detect_features() -> cache::Initializer {
151
151
152
152
if cpu_osxsave {
153
153
// 2. The OS must have signaled the CPU that it supports saving and
154
- // restoring the SSE and AVX registers by setting `XCR0.SSE[1]` and
155
- // `XCR0.AVX[2]` to `1`.
154
+ // restoring the:
155
+ //
156
+ // * SSE -> `XCR0.SSE[1]`
157
+ // * AVX -> `XCR0.AVX[2]`
158
+ // * AVX-512 -> `XCR0.AVX-512[7:5]`.
159
+ //
160
+ // by setting the corresponding bits of `XCR0` to `1`.
156
161
//
157
162
// This is safe because the CPU supports `xsave`
158
163
// and the OS has set `osxsave`.
159
164
let xcr0 = unsafe { _xgetbv ( 0 ) } ;
165
+ // Test `XCR0.SSE[1]` and `XCR0.AVX[2]` with the mask `0b110 == 6`:
160
166
let os_avx_support = xcr0 & 6 == 6 ;
167
+ // Test `XCR0.AVX-512[7:5]` with the mask `0b1110_0000 == 224`:
161
168
let os_avx512_support = xcr0 & 224 == 224 ;
162
169
163
170
// Only if the OS and the CPU support saving/restoring the AVX
You can’t perform that action at this time.
0 commit comments