Skip to content

Simplify the definitions of some x86 intrinsincs - #2271

Merged
folkertdev merged 1 commit into
rust-lang:mainfrom
TDecking:sse-unaligned
Nov 17, 2026
Merged

folkertdev merged 1 commit into
rust-lang:mainfrom
TDecking:sse-unaligned

Conversation

@TDecking

Copy link
Copy Markdown
Contributor

No description provided.

@rustbot

rustbot commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Amanieu, @adamgemmell, @davidtwco, @folkertdev
  • @Amanieu, @adamgemmell, @davidtwco, @folkertdev expanded to Amanieu, adamgemmell, davidtwco, folkertdev
  • Random selection from Amanieu, adamgemmell, davidtwco, folkertdev

@TDecking TDecking changed the title Simplify the definition of _mm_(load|store)u_ps Simplify the definitions of some x86 intrinsincs Nov 17, 2026
Comment thread crates/core_arch/src/x86/sse2.rs Outdated
pub const unsafe fn _mm_storel_epi64(mem_addr: *mut __m128i, a: __m128i) {
ptr::copy_nonoverlapping(ptr::addr_of!(a) as *const u8, mem_addr as *mut u8, 8);
let a = simd_extract!(a.as_u64x2(), 0, u64);
(mem_addr as *const u64).write_unaligned(a);

@folkertdev folkertdev Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
(mem_addr as *const u64).write_unaligned(a);
mem_addr.cast::<u64>().write_unaligned(a);

maybe (the issue here is that you cast to *const and then try to write to it.

View changes since the review

@TDecking

TDecking commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

The PR should be fine now, but it won't pass CI until whatever issue plagues aarch64_be-unknown-linux-gnu is fixed.

@tgross35

Copy link
Copy Markdown
Member

.cast::<...>() should be used anyway, it's preferred over as nowadays because it avoids accidental changes in mutability (like here) and indirection level.

Comment thread crates/core_arch/src/x86/sse2.rs Outdated
Comment on lines 1314 to 1318
#[allow(clippy::cast_ptr_alignment)]
#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")]
pub const unsafe fn _mm_loadu_si128(mem_addr: *const __m128i) -> __m128i {
let mut dst: __m128i = _mm_undefined_si128();
ptr::copy_nonoverlapping(
mem_addr as *const u8,
ptr::addr_of_mut!(dst) as *mut u8,
mem::size_of::<__m128i>(),
);
dst
mem_addr.read_unaligned()
}

@tgross35 tgross35 Nov 17, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All these allows could be expects, but I don't think this one should be needed?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one can indeed be removed.

expect is currently unused in this codebase. What about a follow-up PR to check all uses of allow that can be changed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see why not, but new code should use the better patterns even if old code isn't updated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@rustbot

rustbot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@TDecking
TDecking requested a review from folkertdev November 17, 2026 19:59
@folkertdev
folkertdev added this pull request to the merge queue Nov 17, 2026
Merged via the queue into rust-lang:main with commit 6658bcf Nov 17, 2026
87 checks passed
@TDecking
TDecking deleted the sse-unaligned branch November 17, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants