Skip to content

Conversation

@folkertdev
Copy link
Contributor

@folkertdev folkertdev commented Nov 2, 2025

Subtree update of stdarch to rust-lang/stdarch@b5c1645.

Created using https://github.com/rust-lang/josh-sync.

r? @sayantn


Only the last 2 commits contain manual changes to some incorrect miri tests. The remainder is mechanical, and just synchronizes changes from stdarch.

usamoi and others added 30 commits September 20, 2025 20:13
This reverts commit 24f89ca53d3374ed8d3e0cbadc1dc89eea41acba.
intrinsic-test: test intrinsics with patched `core_arch`
memchr 2.7.6 contains a bugfix for aarch64_be
 - Correct mistake in x86_64/adx.rs where it was not testing `_addcarryx` at all
Use SIMD intrinsics whereever possible
_kshiftli_mask32 and _kshiftli_mask64 to zero out when the amount of shift exceeds the bit length of the input argument.
zero out when the amount of shift exceeds the bit length of the input argument.
to zero out when the amount of shift exceeds 16.
…shift_instructions `core_arch::x86` : Fix the implementation of `_kshift` instructions
Use SIMD intrinsics for `vfmaddsubph` and `vfmsubaddph`
While many intrinsics use `.insn` to generate raw machine code from numbers, all ratified instructions can be symbolic using `.option` directives. By saving the assembler environment with `.option push` then modifying the architecture with `.option arch`, we can temporarily enable certain extensions (as we use `.option pop` immediately after the target instruction, surrounding environment is completely intact in this commit; *almost* completely intact in general). This commit modifies the `pause` *hint* intrinsic to use symbolic *instruction* because we want to expose it even if the Zihintpause extension is unavailable on the target.
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Nov 2, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@folkertdev folkertdev force-pushed the stdarch-sync-nov-2025 branch from a7f0c6c to 7f0a447 Compare November 2, 2025 16:30
@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2025

The Miri subtree was changed

cc @rust-lang/miri

Comment on lines 830 to +841
#[target_feature(enable = "avx")]
unsafe fn test_mm256_permute2f128_ps() {
let a = _mm256_setr_ps(1., 2., 3., 4., 1., 2., 3., 4.);
let b = _mm256_setr_ps(5., 6., 7., 8., 5., 6., 7., 8.);
let r = _mm256_permute2f128_ps::<0x13>(a, b);
let e = _mm256_setr_ps(5., 6., 7., 8., 1., 2., 3., 4.);
let a = _mm256_setr_ps(11., 12., 13., 14., 15., 16., 17., 18.);
let b = _mm256_setr_ps(21., 22., 23., 24., 25., 26., 27., 28.);
let r = _mm256_permute2f128_ps::<0b0001_0011>(a, b);
let e = _mm256_setr_ps(25., 26., 27., 28., 15., 16., 17., 18.);
assert_eq_m256(r, e);

let r = _mm256_permute2f128_ps::<0x44>(a, b);
let e = _mm256_setr_ps(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
assert_eq_m256(r, e);
// Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field.
let r = _mm256_permute2f128_ps::<0b1001_1011>(a, b);
let z = _mm256_setr_ps(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
assert_eq_m256(r, z);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RalfJung the original tests here just fail, even on stable rust https://godbolt.org/z/6KPo7TEjf. So I don't understand why miri accepted this so far.

I've updated the inputs so that it is a bit clearer how the instruction works, see also https://www.felixcloutier.com/x86/vperm2f128.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, in rust-lang/stdarch@13410d0 the implementation stops using LLVM intrinsics, so the incorrect miri fallback implementation is no longer used. We can remove the fallback now.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah looks like the test is just wrong... good catch, thanks!

Cc @eduardosm

Copy link
Member

Choose a reason for hiding this comment

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

I've updated the inputs so that it is a bit clearer how the instruction works

FWIW I don't find this clear at all.^^ However, it's no worse than before. :)

It's very strange that this is using two 8xf32 vectors when supposedly this is permuting values of size 128 bits...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair, lol.

I changed the inputs to make sure that there are no repeating patterns, so that you can sort of puzzle together from the output what part of the input was selected.

The permute here is between the 4 128-bit values (provided as 2 256-bit arguments) of the input. That the values are floats is not even really meaningful. So yeah, weird name, weird signature, you definitely need to read the docs on this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the test could be changed in stdarch too:

https://github.com/rust-lang/stdarch/blob/b5c164540c7821e744c69a8371eec83d40177b6a/crates/core_arch/src/x86/avx.rs#L3930-L3936

I believe the part that was wrong was the zeroing test.

Looking at the changes in stdarch, it looks like a bunch of shim implementations could be removed from miri.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I've updated them mere rust-lang/stdarch#1951.

What other shims can be removed is not really on our radar. Maybe there is some way to (partially) automate the symbols that miri creates a shim for versus the symbols that stdarch uses from llvm?

Copy link
Member

Choose a reason for hiding this comment

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

What other shims can be removed is not really on our radar.

I have opened rust-lang/miri#4659 to make a list.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Miri changes LGTM.

View changes since this review

@sayantn
Copy link
Contributor

sayantn commented Nov 3, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 3, 2025

📌 Commit be22a3f has been approved by sayantn

It is now in the queue for this repository.

@bors bors 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 Nov 3, 2025
bors added a commit that referenced this pull request Nov 3, 2025
Rollup of 3 pull requests Successful merges: - #146260 (add SliceIndex wrapper types Last and Clamp<Idx>) - #148394 (Make explicit that `TypeId`'s layout and size are unstable) - #148402 (stdarch subtree update) r? `@ghost` `@rustbot` modify labels: rollup
@bors bors merged commit 5f4a90e into rust-lang:master Nov 3, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 3, 2025
rust-timer added a commit that referenced this pull request Nov 3, 2025
Rollup merge of #148402 - folkertdev:stdarch-sync-nov-2025, r=sayantn stdarch subtree update Subtree update of `stdarch` to rust-lang/stdarch@b5c1645. Created using https://github.com/rust-lang/josh-sync. r? `@sayantn` --- Only the last 2 commits contain manual changes to some incorrect miri tests. The remainder is mechanical, and just synchronizes changes from stdarch.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Nov 4, 2025
Rollup of 3 pull requests Successful merges: - rust-lang/rust#146260 (add SliceIndex wrapper types Last and Clamp<Idx>) - rust-lang/rust#148394 (Make explicit that `TypeId`'s layout and size are unstable) - rust-lang/rust#148402 (stdarch subtree update) r? `@ghost` `@rustbot` modify labels: rollup
linkmauve added a commit to linkmauve/ruffle that referenced this pull request Nov 4, 2025
In ruffle-rs#21780, an optimisation has been added to use the fjcvtzs ARMv8.3 instruction when available, to convert a f64 into an i32. This made me wonder why core::arch::aarch64 didn’t have an intrinsic for this instruction, so I implemented it in stdarch[1], which got pulled in Rust yesterday[2] (see the tracking issue[3]). This PR makes use of this new intrinsic to remove the unsafe asm!() block, and simplify the code. [1] rust-lang/stdarch#1938 [2] rust-lang/rust#148402 [3] rust-lang/rust#147555
linkmauve added a commit to linkmauve/ruffle that referenced this pull request Nov 4, 2025
In ruffle-rs#21780, an optimisation has been added to use the fjcvtzs ARMv8.3 instruction when available, to convert a f64 into an i32. This made me wonder why core::arch::aarch64 didn’t have an intrinsic for this instruction, so I implemented it in stdarch[1], which got pulled in Rust yesterday[2] (see the tracking issue[3]). This PR makes use of this new intrinsic to remove the unsafe asm!() block, and simplify the code. [1] rust-lang/stdarch#1938 [2] rust-lang/rust#148402 [3] rust-lang/rust#147555
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-libs Relevant to the library team, which will review and decide on the PR/issue.