- Notifications
You must be signed in to change notification settings - Fork 13.9k
stdarch subtree update #148402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdarch subtree update #148402
Conversation
This reverts commit 24f89ca53d3374ed8d3e0cbadc1dc89eea41acba.
intrinsic-test: test intrinsics with patched `core_arch`
memchr 2.7.6 contains a bugfix for aarch64_be
Update memchr to 2.7.6
- 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`
Fix xsave segfaults
Fixes for non-temporal intrinsics
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a7f0c6c to 7f0a447 Compare | The Miri subtree was changed cc @rust-lang/miri |
| #[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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
7f0a447 to d997c30 Compare This comment has been minimized.
This comment has been minimized.
it is no longer used (and was also incorrect)
d997c30 to be22a3f Compare There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Miri changes LGTM.
| @bors r+ |
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.
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
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
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
Subtree update of
stdarchto 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.