Repository navigation
Add the clflushopt x86 target feature - #157098
Merged
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This was referenced May 29, 2026
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
`CLFLUSHOPT` is a standalone x86 CPUID feature (Intel Skylake+ / AMD Excavator+, ~2015) not part of any psABI microarchitecture level, so it needs its own unstable target feature, gated behind `clflushopt_target_feature`. This is the compiler half of exposing the `_mm_clflushopt` intrinsic; the stdarch half is blocked on this landing. Also bless two UI test references (check-cfg/target_feature and target-feature/invalid-attribute) that enumerate the full set of valid target features, since `clflushopt` is now part of that list.
jlpetz
force-pushed
the
clflushopt-target-feature
branch
from
May 29, 2026 10:10
1c1d8ea to
0980491
Compare
Contributor
|
r? me |
folkertdev
reviewed
May 29, 2026
Contributor
There was a problem hiding this comment.
Could you also add the feature to the is_x86_feature_detected! macro defined at
https://github.com/rust-lang/rust/blob/main/library/std_detect/src/detect/arch/x86.rs
and add a test for it in library/std_detect/tests/x86-specific.rs?
This comment has been minimized.
This comment has been minimized.
Wire up runtime detection for the `clflushopt` feature: add it to the `is_x86_feature_detected!` feature list (gated on `clflushopt_target_feature`), enable it from CPUID leaf 7 EBX bit 23, and add it to the std_detect x86-specific dump test.
Collaborator
|
Some changes occurred in cc @Amanieu, @folkertdev, @sayantn |
Contributor
Author
Thanks for the feedback, I've tried to address it. |
Contributor
|
Thanks! @bors r+ rollup |
Contributor
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 16 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157098 (Add the `clflushopt` x86 target feature) - #157103 (Add reproducibly failing tests for parallel frontend) - #157111 (Update target maintainer for x86_64-unknown-linux-none) - #157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - #157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - #157120 (Cleanups around attribute target checking) Failed merges: - #157100 (Some more per owner things)
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 16 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157098 (Add the `clflushopt` x86 target feature) - #157103 (Add reproducibly failing tests for parallel frontend) - #157111 (Update target maintainer for x86_64-unknown-linux-none) - #157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - #157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - #157120 (Cleanups around attribute target checking) Failed merges: - #157100 (Some more per owner things)
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 16 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157098 (Add the `clflushopt` x86 target feature) - #157103 (Add reproducibly failing tests for parallel frontend) - #157111 (Update target maintainer for x86_64-unknown-linux-none) - #157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - #157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - #157120 (Cleanups around attribute target checking) Failed merges: - #157100 (Some more per owner things)
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 16 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157098 (Add the `clflushopt` x86 target feature) - #157103 (Add reproducibly failing tests for parallel frontend) - #157111 (Update target maintainer for x86_64-unknown-linux-none) - #157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - #157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - #157120 (Cleanups around attribute target checking) Failed merges: - #157100 (Some more per owner things)
rust-bors Bot
pushed a commit
that referenced
this pull request
May 29, 2026
…uwer Rollup of 16 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157098 (Add the `clflushopt` x86 target feature) - #157103 (Add reproducibly failing tests for parallel frontend) - #157111 (Update target maintainer for x86_64-unknown-linux-none) - #157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - #157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - #157120 (Cleanups around attribute target checking) Failed merges: - #157100 (Some more per owner things)
rust-bors Bot
pushed a commit
that referenced
this pull request
May 30, 2026
…uwer Rollup of 16 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157098 (Add the `clflushopt` x86 target feature) - #157103 (Add reproducibly failing tests for parallel frontend) - #157111 (Update target maintainer for x86_64-unknown-linux-none) - #157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - #157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - #157120 (Cleanups around attribute target checking) Failed merges: - #157100 (Some more per owner things)
makai410
pushed a commit
to makai410/rust
that referenced
this pull request
Oct 1, 2026
…nathanBrouwer Rollup of 16 pull requests Successful merges: - rust-lang#149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - rust-lang#156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - rust-lang#156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - rust-lang#157053 (Eagerly resolve delegations in late resolution) - rust-lang#157068 (NVPTX: Remove the unstable ptx linker flavor) - rust-lang#157076 (Various proc-macro related code cleanups) - rust-lang#157106 (add ABI check logic for wasm) - rust-lang#154835 (std::offload sharedmem) - rust-lang#157065 (Stabilize `Path::is_empty`) - rust-lang#157088 (Improve suggestions for malformed deprecated attribute) - rust-lang#157098 (Add the `clflushopt` x86 target feature) - rust-lang#157103 (Add reproducibly failing tests for parallel frontend) - rust-lang#157111 (Update target maintainer for x86_64-unknown-linux-none) - rust-lang#157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - rust-lang#157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - rust-lang#157120 (Cleanups around attribute target checking) Failed merges: - rust-lang#157100 (Some more per owner things)
makai410
pushed a commit
to makai410/rustc_public
that referenced
this pull request
Oct 1, 2026
…uwer Rollup of 16 pull requests Successful merges: - rust-lang/rust#149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - rust-lang/rust#156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - rust-lang/rust#156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - rust-lang/rust#157053 (Eagerly resolve delegations in late resolution) - rust-lang/rust#157068 (NVPTX: Remove the unstable ptx linker flavor) - rust-lang/rust#157076 (Various proc-macro related code cleanups) - rust-lang/rust#157106 (add ABI check logic for wasm) - rust-lang/rust#154835 (std::offload sharedmem) - rust-lang/rust#157065 (Stabilize `Path::is_empty`) - rust-lang/rust#157088 (Improve suggestions for malformed deprecated attribute) - rust-lang/rust#157098 (Add the `clflushopt` x86 target feature) - rust-lang/rust#157103 (Add reproducibly failing tests for parallel frontend) - rust-lang/rust#157111 (Update target maintainer for x86_64-unknown-linux-none) - rust-lang/rust#157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - rust-lang/rust#157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - rust-lang/rust#157120 (Cleanups around attribute target checking) Failed merges: - rust-lang/rust#157100 (Some more per owner things)
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Oct 4, 2026
…=folkertdev
Add the `movdir64b` and `movdiri` x86 target features
Adds the unstable `movdir64b` and `movdiri` x86 target features, gated behind `#![feature(movdir64b_target_feature)]` and `#![feature(movdiri_target_feature)]`, and runtime detection with `is_x86_feature_detected!("movdir64b")` / `is_x86_feature_detected!("movdiri")` (CPUID.(EAX=7,ECX=0):ECX[28] and ECX[27]).
`MOVDIR64B` moves 64 bytes from memory to a 64-byte aligned destination as a single direct store; `MOVDIRI` stores a 32- or 64-bit integer as a direct store. Both are on Intel Tiger Lake / Alder Lake and later, Sapphire Rapids and later Xeons, and AMD Zen 5. They're standalone CPUID features that aren't part of any psABI microarchitecture level, so they need their own feature flags.
**This is the compiler half of a two-PR feature, like `clflushopt` in rust-lang#157098.** The `_movdir64b`, `_directstoreu_u32` and `_directstoreu_u64` intrinsics (rust-lang/stdarch#2239) can't compile until these target features exist, so the stdarch PR is blocked on this one merging and syncing into stdarch's pinned toolchain.
- Tracking issue: rust-lang#163741
- Unblocks intrinsics: rust-lang/stdarch#2239
Today the only way to emit these instructions from Rust is `asm!`, which also hides them from LLVM: a copy loop through `llvm.x86.movdir64b` gets unrolled and the source address becomes a displacement, while the `asm!` version stays one instruction per iteration with both addresses in registers.
`movdir64b` and `movdiri` are LLVM's feature names, so they map 1:1 through `to_llvm_features` with no remap entry. I ran the two new feature-gate tests, `check-cfg/target_feature` and `target-feature/invalid-attribute`, the std_detect tests (which report both features as `true` on a Xeon 6975P-C), and tidy locally on x86_64-pc-windows-msvc.
r? @folkertdev
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Oct 4, 2026
…=folkertdev
Add the `movdir64b` and `movdiri` x86 target features
Adds the unstable `movdir64b` and `movdiri` x86 target features, gated behind `#![feature(movdir64b_target_feature)]` and `#![feature(movdiri_target_feature)]`, and runtime detection with `is_x86_feature_detected!("movdir64b")` / `is_x86_feature_detected!("movdiri")` (CPUID.(EAX=7,ECX=0):ECX[28] and ECX[27]).
`MOVDIR64B` moves 64 bytes from memory to a 64-byte aligned destination as a single direct store; `MOVDIRI` stores a 32- or 64-bit integer as a direct store. Both are on Intel Tiger Lake / Alder Lake and later, Sapphire Rapids and later Xeons, and AMD Zen 5. They're standalone CPUID features that aren't part of any psABI microarchitecture level, so they need their own feature flags.
**This is the compiler half of a two-PR feature, like `clflushopt` in rust-lang#157098.** The `_movdir64b`, `_directstoreu_u32` and `_directstoreu_u64` intrinsics (rust-lang/stdarch#2239) can't compile until these target features exist, so the stdarch PR is blocked on this one merging and syncing into stdarch's pinned toolchain.
- Tracking issue: rust-lang#163741
- Unblocks intrinsics: rust-lang/stdarch#2239
Today the only way to emit these instructions from Rust is `asm!`, which also hides them from LLVM: a copy loop through `llvm.x86.movdir64b` gets unrolled and the source address becomes a displacement, while the `asm!` version stays one instruction per iteration with both addresses in registers.
`movdir64b` and `movdiri` are LLVM's feature names, so they map 1:1 through `to_llvm_features` with no remap entry. I ran the two new feature-gate tests, `check-cfg/target_feature` and `target-feature/invalid-attribute`, the std_detect tests (which report both features as `true` on a Xeon 6975P-C), and tidy locally on x86_64-pc-windows-msvc.
r? @folkertdev
rust-bors Bot
pushed a commit
that referenced
this pull request
Oct 4, 2026
Rollup merge of #163742 - jlpetz:movdir64b-target-feature, r=folkertdev Add the `movdir64b` and `movdiri` x86 target features Adds the unstable `movdir64b` and `movdiri` x86 target features, gated behind `#![feature(movdir64b_target_feature)]` and `#![feature(movdiri_target_feature)]`, and runtime detection with `is_x86_feature_detected!("movdir64b")` / `is_x86_feature_detected!("movdiri")` (CPUID.(EAX=7,ECX=0):ECX[28] and ECX[27]). `MOVDIR64B` moves 64 bytes from memory to a 64-byte aligned destination as a single direct store; `MOVDIRI` stores a 32- or 64-bit integer as a direct store. Both are on Intel Tiger Lake / Alder Lake and later, Sapphire Rapids and later Xeons, and AMD Zen 5. They're standalone CPUID features that aren't part of any psABI microarchitecture level, so they need their own feature flags. **This is the compiler half of a two-PR feature, like `clflushopt` in #157098.** The `_movdir64b`, `_directstoreu_u32` and `_directstoreu_u64` intrinsics (rust-lang/stdarch#2239) can't compile until these target features exist, so the stdarch PR is blocked on this one merging and syncing into stdarch's pinned toolchain. - Tracking issue: #163741 - Unblocks intrinsics: rust-lang/stdarch#2239 Today the only way to emit these instructions from Rust is `asm!`, which also hides them from LLVM: a copy loop through `llvm.x86.movdir64b` gets unrolled and the source address becomes a displacement, while the `asm!` version stays one instruction per iteration with both addresses in registers. `movdir64b` and `movdiri` are LLVM's feature names, so they map 1:1 through `to_llvm_features` with no remap entry. I ran the two new feature-gate tests, `check-cfg/target_feature` and `target-feature/invalid-attribute`, the std_detect tests (which report both features as `true` on a Xeon 6975P-C), and tidy locally on x86_64-pc-windows-msvc. r? @folkertdev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the unstable
clflushoptx86 target feature, gated behind#![feature(clflushopt_target_feature)].CLFLUSHOPTis a standalone x86 CPUID feature (Intel Skylake+ / AMDExcavator+, ~2015) that is not part of any psABI microarchitecture level, so it
needs its own feature flag.
This is the compiler half of a two-PR feature and is a hard dependency for the
stdarch side. The
_mm_clflushoptintrinsic (rust-lang/stdarch#1456) cannotcompile until this target feature exists, so the stdarch PR is blocked on this
one merging and syncing into stdarch's pinned toolchain.
clflushopt_target_feature#157096_mm_clflushoptstdarch#1456This mirrors the existing unstable x86 target features (e.g.
movrs,apxf).clflushoptis a standard LLVM x86 feature name, so it maps 1:1 throughto_llvm_featureswith no remap entry needed.r? compiler