Skip to content

Add the movdir64b and movdiri x86 target features - #163742

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
jlpetz:movdir64b-target-feature
Oct 4, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
jlpetz:movdir64b-target-feature

Conversation

@jlpetz

@jlpetz jlpetz commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

jlpetz added 3 commits October 4, 2026 17:29
`MOVDIR64B` and `MOVDIRI` (direct stores of 64 bytes and of a 32/64-bit
integer) are standalone x86 CPUID features, on Intel Tiger Lake and
Sapphire Rapids onwards and AMD Zen 5, that are not part of any psABI
microarchitecture level. They need their own unstable target features,
gated behind `movdir64b_target_feature` and `movdiri_target_feature`.

This is the compiler half of exposing the `_movdir64b`,
`_directstoreu_u32` and `_directstoreu_u64` intrinsics; the stdarch half
is blocked on this landing.

Also update the check-cfg/target_feature UI test reference, which
enumerates the full set of valid target features.
Wire up runtime detection for both features: add them to the
`is_x86_feature_detected!` feature list (gated on
`movdir64b_target_feature` and `movdiri_target_feature`), enable them from
CPUID leaf 7 ECX bits 28 and 27, and add them to the std_detect
x86-specific dump test.
@rustbot

rustbot commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Target features are being changed; ensure all ABI effects are being accounted for

cc @RalfJung

Some changes occurred in std_detect

cc @Amanieu, @folkertdev, @sayantn

@rustbot rustbot added 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. labels Oct 4, 2026
@folkertdev

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 06b69b5 has been approved by folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 4, 2026
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
…uwer

Rollup of 6 pull requests

Successful merges:

 - #161491 (Rip out old solver coherence)
 - #163223 (regression test for async handler normalization ICE)
 - #163653 (callconv: mips64: Match GCC for alignment of 16-byte scalars)
 - #163742 (Add the `movdir64b` and `movdiri` x86 target features)
 - #163752 (Revert "implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N]")
 - #163755 (fix -Z track-diagnostics for errors and lints emitted from rustc_attr_parsing)
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #161491 (Rip out old solver coherence)
 - #163533 (Run cg_gcc tests with the correct compiler)
 - #163223 (regression test for async handler normalization ICE)
 - #163367 (simplify rustc_log a bit)
 - #163622 (x86: c-variadic functions don't use registers with `-Zregparm`)
 - #163653 (callconv: mips64: Match GCC for alignment of 16-byte scalars)
 - #163665 (Parser: Refactor & better document `should_continue_as_assoc_expr` & `can_continue_expr_unambiguously`)
 - #163742 (Add the `movdir64b` and `movdiri` x86 target features)
 - #163752 (Revert "implement PartialEq<VecDeque<U>> for Vec<T>, &[T], &mut [T], [T; N], &[T; N] and &mut [T; N]")
@rust-bors
rust-bors Bot merged commit 1b9f376 into rust-lang:main Oct 4, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 4, 2026
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
jlpetz added a commit to jlpetz/plumb that referenced this pull request Oct 8, 2026
- Each crate carries LICENSE-APACHE and LICENSE-MIT, so `cargo package`
  includes them.
- plumb_tiles' example is now `tile_kernels`; both crates had an example
  called `asm_kernels`.
- README gains an Upstream section, and the docs link the PRs that
  would retire `asm!`: llvm/llvm-project#229240 for NT stores,
  rust-lang/rust#163742 and rust-lang/stdarch#2239 for MOVDIR64B, and
  llvm/llvm-project#229025 for the AMX intrinsics' memory effects.
- TODO 1 closes (first CI runs green); TODO 5 records #228875's close
  and the fixes offered on #229240.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

3 participants