Skip to content
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

Don't field-project (.0) into SIMD types #1740

Merged
merged 1 commit into from
Mar 6, 2025

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Mar 5, 2025

Part of rust-lang/compiler-team#838, as people have already mentioned in comments like

// NOTE: This deliberately doesn't just use `&self.0` because it may soon be banned
// see https://github.com/rust-lang/compiler-team/issues/838

@rustbot
Copy link
Collaborator

rustbot commented Mar 5, 2025

r? @Amanieu

rustbot has assigned @Amanieu.
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

@scottmcm
Copy link
Member Author

scottmcm commented Mar 5, 2025

@folkertdev, since you've mentioned s390x recently, do you know why I might be getting s390x failures from this?

Seems like they're related to f16 somehow...

rustc-LLVM ERROR: Cannot select: 0x7f52ab2d3bd0: f32 = fp16_to_fp 0x7f52ab2d3cb0, /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/slice/cmp.rs:67:16 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/slice/cmp.rs:15:9 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/array/equality.rs:138:9 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/array/equality.rs:10:9 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/cmp.rs:1922:13 @[ crates/core_arch/src/simd.rs:58:17 ] ] ] ] ]
  0x7f52ab2d3cb0: i32,ch = load<(dereferenceable load (s16) from %ir.1, align 8, !alias.scope !1472, !noalias !1471), zext from i16> 0x7f52ab26b920, 0x7f52ab2d3620, undef:i64, /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/slice/cmp.rs:67:16 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/slice/cmp.rs:15:9 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/array/equality.rs:138:9 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/array/equality.rs:10:9 @[ /rustc/f9e0239a7bc813b4aceffc7f069f4797cde3175c/library/core/src/cmp.rs:1922:13 @[ crates/core_arch/src/simd.rs:58:17 ] ] ] ] ]
    0x7f52ab2d3620: i64,ch = CopyFromReg 0x7f52ab26b920, Register:i64 %2
      0x7f52ab2d3a80: i64 = Register %2
    0x7f52ab2d3230: i64 = undef
In function: _ZN74_$LT$core_arch..core_arch..simd..f16x4$u20$as$u20$core..cmp..PartialEq$GT$2eq17h65faeea59d4b4257E
error: could not compile `core_arch` (lib)

@scottmcm scottmcm force-pushed the no-simd-projection branch from 34504e5 to 77687d6 Compare March 5, 2025 07:55
@folkertdev
Copy link
Contributor

folkertdev commented Mar 5, 2025

it's because f16 is just not really supported on s390x currently, e.g. even a simple f16 comparison fails to compile with a very similar error:

https://godbolt.org/z/xGTEevEjb

edit: seems like we're making progress on this

rust-lang/rust#138022
llvm/llvm-project#109164

@tgross35
Copy link

tgross35 commented Mar 5, 2025

In std/build.rs there is a list of platforms that have problems with f16 and f128. Most of them are pretty quiet and only show up when you try to use specific ops, but s390x stands out since it’s basically an instant crash if half shows up in the IR.

The workaround was using #[inline] on any functions containing these types so we don’t codegen, since rust-lang/rust#133050 that’s automatic but limited. Maybe this PR is hitting a case that isn’t auto-inlined?

edit: oh, yeah, you fixed it already

@folkertdev
Copy link
Contributor

yeah the #[inline] on the manual PartialEq implementation seems to have done the trick

@scottmcm scottmcm force-pushed the no-simd-projection branch from 507752d to f27f1ec Compare March 5, 2025 16:05
@scottmcm
Copy link
Member Author

scottmcm commented Mar 5, 2025

Looks like I was overcomplicated things in 77687d6 -- I squashed everything down back to just using the arrays, which seems fine since the == isn't usually actually used, just in tests, so inlining so they don't need to actually codegen on all platforms seems to have "solved" the problems.

@Amanieu Amanieu added this pull request to the merge queue Mar 6, 2025
Merged via the queue into rust-lang:master with commit 58538b1 Mar 6, 2025
60 checks passed
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.

5 participants