Skip to content

Add the clflushopt x86 target feature#157098

Open
jlpetz wants to merge 3 commits into
rust-lang:mainfrom
jlpetz:clflushopt-target-feature
Open

Add the clflushopt x86 target feature#157098
jlpetz wants to merge 3 commits into
rust-lang:mainfrom
jlpetz:clflushopt-target-feature

Conversation

@jlpetz
Copy link
Copy Markdown

@jlpetz jlpetz commented May 29, 2026

Adds the unstable clflushopt x86 target feature, gated behind
#![feature(clflushopt_target_feature)].

CLFLUSHOPT is a standalone x86 CPUID feature (Intel Skylake+ / AMD
Excavator+, ~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_clflushopt intrinsic (rust-lang/stdarch#1456) cannot
compile until this target feature exists, so the stdarch PR is blocked on this
one merging and syncing into stdarch's pinned toolchain.

This mirrors the existing unstable x86 target features (e.g. movrs, apxf).
clflushopt is a standard LLVM x86 feature name, so it maps 1:1 through
to_llvm_features with no remap entry needed.

r? compiler

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 29, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

jlpetz added 2 commits May 29, 2026 20:09
`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 jlpetz force-pushed the clflushopt-target-feature branch from 1c1d8ea to 0980491 Compare May 29, 2026 10:10
@folkertdev
Copy link
Copy Markdown
Contributor

r? me

@rustbot rustbot assigned folkertdev and unassigned JohnTitor May 29, 2026
Copy link
Copy Markdown
Contributor

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

View changes since this review

@rust-log-analyzer

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.
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 29, 2026

Some changes occurred in std_detect

cc @Amanieu, @folkertdev, @sayantn

@jlpetz
Copy link
Copy Markdown
Author

jlpetz commented May 29, 2026

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?

View changes since this review

Thanks for the feedback, I've tried to address it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants