diff options
| author | bors <bors@rust-lang.org> | 2024-03-22 04:06:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-22 04:06:25 +0000 |
| commit | cdb683f6e4b0774b85c60eebe12af87f29d8ee4d (patch) | |
| tree | e54736c22d842a591a8f768e7f784806b67b9ac0 /tests/codegen | |
| parent | b57a10c39d2a2da7389d029595d7fff6ac9cbf5a (diff) | |
| parent | f8fd23a2add24de796b2fab197920d3fd349941a (diff) | |
| download | rust-cdb683f6e4b0774b85c60eebe12af87f29d8ee4d.tar.gz rust-cdb683f6e4b0774b85c60eebe12af87f29d8ee4d.zip | |
Auto merge of #122024 - clubby789:remove-spec-option-pe, r=jhpratt
Remove SpecOptionPartialEq With the recent LLVM bump, the specialization for Option::partial_eq on types with niches is no longer necessary. I kept the manual implementation as it still gives us better codegen than the derive (will look at this seperately). Also implemented PartialOrd/Ord by hand as it _somewhat_ improves codegen for #49892: https://godbolt.org/z/vx5Y6oW4Y
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/option-niche-eq.rs (renamed from tests/codegen/option-nonzero-eq.rs) | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/tests/codegen/option-nonzero-eq.rs b/tests/codegen/option-niche-eq.rs index f637b1aef97..8b8044e9b75 100644 --- a/tests/codegen/option-nonzero-eq.rs +++ b/tests/codegen/option-niche-eq.rs @@ -1,4 +1,5 @@ //@ compile-flags: -O -Zmerge-functions=disabled +//@ min-llvm-version: 18 #![crate_type = "lib"] #![feature(generic_nonzero)] @@ -7,9 +8,6 @@ use core::cmp::Ordering; use core::ptr::NonNull; use core::num::NonZero; -// See also tests/assembly/option-nonzero-eq.rs, for cases with `assume`s in the -// LLVM and thus don't optimize down clearly here, but do in assembly. - // CHECK-lABEL: @non_zero_eq #[no_mangle] pub fn non_zero_eq(l: Option<NonZero<u32>>, r: Option<NonZero<u32>>) -> bool { @@ -36,3 +34,42 @@ pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool { // CHECK-NEXT: ret i1 l == r } + +// CHECK-lABEL: @ordering_eq +#[no_mangle] +pub fn ordering_eq(l: Option<Ordering>, r: Option<Ordering>) -> bool { + // CHECK: start: + // CHECK-NEXT: icmp eq i8 + // CHECK-NEXT: ret i1 + l == r +} + +#[derive(PartialEq)] +pub enum EnumWithNiche { + A, + B, + C, + D, + E, + F, + G, +} + +// CHECK-lABEL: @niche_eq +#[no_mangle] +pub fn niche_eq(l: Option<EnumWithNiche>, r: Option<EnumWithNiche>) -> bool { + // CHECK: start: + // CHECK-NEXT: icmp eq i8 + // CHECK-NEXT: ret i1 + l == r +} + +// FIXME: This should work too +// // FIXME-CHECK-lABEL: @bool_eq +// #[no_mangle] +// pub fn bool_eq(l: Option<bool>, r: Option<bool>) -> bool { +// // FIXME-CHECK: start: +// // FIXME-CHECK-NEXT: icmp eq i8 +// // FIXME-CHECK-NEXT: ret i1 +// l == r +// } |
