diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-12-01 07:52:21 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-12-01 07:52:21 -0500 |
| commit | dd4829ecfc259eebc0e42e3f72d2d61911ee010e (patch) | |
| tree | 607dabec0efef7e5fe71297e2c5f0b512b0859eb /docs/cpu_features.md | |
| parent | e12f7f9f9a82288ee0424be753d383eb3eb7843f (diff) | |
| parent | 1723dec94510d0aa3d99e795f0a656970c1f00e9 (diff) | |
Merge remote-tracking branch 'origin/main' into push/main-1130
# Conflicts:
# d3d12/docs/switches.md
Diffstat (limited to 'docs/cpu_features.md')
| -rw-r--r-- | docs/cpu_features.md | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/docs/cpu_features.md b/docs/cpu_features.md index 47ffd81dc..9c4e97ea3 100644 --- a/docs/cpu_features.md +++ b/docs/cpu_features.md | |||
| @@ -43,10 +43,27 @@ Each flagged site was read by hand in a private copy (not quoted here): | |||
| 43 | - The 8 privileged and 1 `int n` hits are data: tables of 32-bit offsets placed in `.text` (some inside a `.pdata` | 43 | - The 8 privileged and 1 `int n` hits are data: tables of 32-bit offsets placed in `.text` (some inside a `.pdata` |
| 44 | range) that the linear sweep decodes as instructions. They are listed for completeness, not as code to replace. | 44 | range) that the linear sweep decodes as instructions. They are listed for completeness, not as code to replace. |
| 45 | 45 | ||
| 46 | No AVX-512, VAES, VPCLMULQDQ, SHA, RDPID, RDPRU, XOP, FMA4, TBM, SYSCALL or SYSENTER instruction was found. The | 46 | No AVX-512, VAES, VPCLMULQDQ, SHA, RDPID, RDPRU, XOP, FMA4, TBM, SYSCALL or SYSENTER instruction was found. No RDTSC, |
| 47 | 256-bit integer, FMA3, F16C, BMI1/2, ADX, MOVBE, AES-NI and PCLMULQDQ instructions it uses are on every Intel CPU | 47 | RDTSCP, RDRAND, RDSEED, FSGSBASE or CLFLUSHOPT instruction is in the image either. The remaining features counted by |
| 48 | since Haswell/Broadwell and every AMD CPU since Zen, so they are counted but not flagged. No RDTSC or RDTSCP is | 48 | `tools/cpu_feature_scan.py` (at `0b11d86b`) are in its `baseline` class — present on every Intel CPU since |
| 49 | in the image. | 49 | Haswell/Broadwell and every AMD CPU since Zen: |
| 50 | |||
| 51 | | Feature | Sites | Inside `.pdata` | Outside `.pdata` | Notes | | ||
| 52 | |---|---:|---:|---:|---| | ||
| 53 | | `AVX` | 2,981,637 | 2,871,070 | 110,567 | Includes 31,970 `vbroadcastss` and 131 `vbroadcastsd` sites in `.pdata` with an `xmm` register source (`mod == 3`), which are AVX2 rather than AVX1 | | ||
| 54 | | `FMA` (FMA3) | 204,279 | 200,924 | 3,355 | 45 mnemonics (`132`/`213`/`231`, `ps`/`pd`/`ss`/`sd`, including 3 `vfmaddsub*`/`vfmsubadd*` sites) | | ||
| 55 | | `AVX2` | 86,018 | 81,500 | 4,518 | Zero `vgather*` or `vpgather*` sites; 284 of the `.pdata` hits are AVX1 mnemonics that share the `vp` prefix (`234` `vptest`, `42` `vperm2f128`, `8` `vpermilps`) | | ||
| 56 | | `BMI1` | 60,850 | 58,398 | 2,452 | `bextr` (21,546), `andn` (17,585), `tzcnt` (11,827), `blsr` (7,301), `blsi` (139); zero `blsmsk` | | ||
| 57 | | `BMI2` | 14,959 | 12,403 | 2,556 | `shlx` (7,581), `mulx` (1,612), `shrx` (1,309), `rorx` (1,064), `bzhi` (808), `sarx` (29); zero `pdep` or `pext` in `.pdata` | | ||
| 58 | | `AES` | 3,390 | 13 | 3,377 | `vaesimc` in `.pdata`; the hits outside `.pdata` are data | | ||
| 59 | | `F16C` | 3,303 | 2,966 | 337 | `vcvtph2ps` (1,526) and `vcvtps2ph` (1,440) | | ||
| 60 | | `ADX` | 2,678 | 0 | 2,678 | Data outside `.pdata`; zero sites inside `.pdata` | | ||
| 61 | | `PCLMULQDQ` | 1,128 | 0 | 1,128 | Data outside `.pdata`; zero sites inside `.pdata` | | ||
| 62 | | `POPCNT` | 458 | 442 | 16 | — | | ||
| 63 | | `MOVBE` | 422 | 195 | 227 | — | | ||
| 64 | | `LZCNT` | 321 | 294 | 27 | 149 4-byte and 145 5-to-9-byte encodings in `.pdata` | | ||
| 65 | | `CX16` | 56 | 56 | 0 | `cmpxchg16b` | | ||
| 66 | | `PREFETCHW` | 5 | 5 | 0 | `0F 0D /1`: architectural NOP on Intel 64 CPUs without `PREFETCHW` | | ||
| 50 | 67 | ||
| 51 | ## What it means for the runtime | 68 | ## What it means for the runtime |
| 52 | 69 | ||
| @@ -70,6 +87,31 @@ in the image. | |||
| 70 | 87 | ||
| 71 | Not measured: which of these sites a boot reaches, and in which order. | 88 | Not measured: which of these sites a boot reaches, and in which order. |
| 72 | 89 | ||
| 90 | ### Hosts with AVX1 and SSE4.2 (Sandy Bridge and Ivy Bridge) | ||
| 91 | |||
| 92 | An Intel Sandy Bridge or Ivy Bridge host (for example an Intel Core i7-2600, `CPUID.1:ECX = 0x1FBAE3FF`, `XCR0 = 0x7`) | ||
| 93 | has 256-bit `YMM0`–`YMM15`, `XSAVE`/`OSXSAVE`, `AVX`, `SSE4.2`, `POPCNT`, `CX16`, `AES-NI` and `PCLMULQDQ`, so it | ||
| 94 | passes the `host_cpu` AVX preflight, executes the 2,839,253 genuine AVX1 `.pdata` sites (`2,871,070` minus the 32,101 | ||
| 95 | register-source `vbroadcastss`/`vbroadcastsd` sites, plus the 284 `vp`-prefixed AVX1 sites) natively, and treats the 5 | ||
| 96 | `PREFETCHW` sites (`0F 0D /1`) as hint NOPs (Intel SDM Vol. 2B). What it lacks inside `.pdata` is the Haswell/ABM | ||
| 97 | delta: `FMA` (200,924), `AVX2` (81,216 plus 32,101 register-source `vbroadcastss`/`vbroadcastsd`), `BMI1` (58,398), | ||
| 98 | `BMI2` (12,403), `F16C` (2,966 on Sandy Bridge; native on Ivy Bridge), `LZCNT` (294) and `MOVBE` (195). | ||
| 99 | |||
| 100 | Those instructions split into two execution classes on a pre-Haswell CPU: | ||
| 101 | |||
| 102 | - **Fault with `#UD` (`STATUS_ILLEGAL_INSTRUCTION`):** every VEX `0F38`/`0F3A` instruction in that set (`FMA3`, `F16C`, | ||
| 103 | `bextr`/`andn`/`blsr`/`blsi`, `BMI2`, `AVX2` broadcasts/permutes/blends/variable shifts, and register-source | ||
| 104 | `vbroadcastss`/`vbroadcastsd`), 256-bit `0F`-map integer `vp* ymm` operations, and `MOVBE`. | ||
| 105 | - **Do not fault (`LZCNT` and `TZCNT`):** legacy `LZCNT` (`F3 0F BD`) and `TZCNT` (`F3 0F BC`) have no VEX form in | ||
| 106 | x86-64, and a CPU without `LZCNT`/`BMI1` ignores the `F3` prefix and executes `BSR` or `BSF` instead (Intel SDM | ||
| 107 | Vol. 2A/2B). `BSR` returns the bit index (`width - 1 - lzcnt`) rather than the leading-zero count and leaves the | ||
| 108 | destination undefined when the source is zero. `BSF` writes the same bit index as `TZCNT` for non-zero inputs, but | ||
| 109 | leaves `CF` undefined and leaves the destination unmodified when the source is zero, whereas 988 of the 11,827 | ||
| 110 | `.pdata` `tzcnt` sites are immediately followed by a `CF`-reading instruction (`793` `cmovb`, `174` `cmovae`, `20` | ||
| 111 | `jae`, `1` `jb`). Supporting an `AVX1` host therefore requires rewriting `LZCNT` and `TZCNT` sites before code runs | ||
| 112 | (149 of the 294 `.pdata` `lzcnt` sites are 4-byte `F3 0F BD /r` encodings without REX, shorter than a 5-byte | ||
| 113 | `jmp rel32`) rather than relying on `#UD`. | ||
| 114 | |||
| 73 | ### Hosts without AVX | 115 | ### Hosts without AVX |
| 74 | 116 | ||
| 75 | Measured on one host: Intel Xeon X5675 (Westmere, SSE4.2; no AVX, AVX2, FMA, BMI2 or XSAVE), Fedora 44, | 117 | Measured on one host: Intel Xeon X5675 (Westmere, SSE4.2; no AVX, AVX2, FMA, BMI2 or XSAVE), Fedora 44, |