2022-10-27 12:40:45 +00:00
|
|
|
//@ compile-flags: -O -Zmerge-functions=disabled
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
extern crate core;
|
2023-01-18 06:44:16 +00:00
|
|
|
use core::cmp::Ordering;
|
2024-02-22 13:59:52 +00:00
|
|
|
use core::num::NonZero;
|
2024-05-29 04:11:20 +00:00
|
|
|
use core::ptr::NonNull;
|
2022-10-27 12:40:45 +00:00
|
|
|
|
2024-05-11 10:09:21 +00:00
|
|
|
// CHECK-LABEL: @non_zero_eq
|
2022-10-27 12:40:45 +00:00
|
|
|
#[no_mangle]
|
2024-02-22 13:59:52 +00:00
|
|
|
pub fn non_zero_eq(l: Option<NonZero<u32>>, r: Option<NonZero<u32>>) -> bool {
|
2022-10-27 12:40:45 +00:00
|
|
|
// CHECK: start:
|
|
|
|
// CHECK-NEXT: icmp eq i32
|
|
|
|
// CHECK-NEXT: ret i1
|
|
|
|
l == r
|
|
|
|
}
|
|
|
|
|
2024-05-11 10:09:21 +00:00
|
|
|
// CHECK-LABEL: @non_zero_signed_eq
|
2022-10-27 12:40:45 +00:00
|
|
|
#[no_mangle]
|
2024-02-22 13:59:52 +00:00
|
|
|
pub fn non_zero_signed_eq(l: Option<NonZero<i64>>, r: Option<NonZero<i64>>) -> bool {
|
2022-10-27 12:40:45 +00:00
|
|
|
// CHECK: start:
|
|
|
|
// CHECK-NEXT: icmp eq i64
|
|
|
|
// CHECK-NEXT: ret i1
|
|
|
|
l == r
|
|
|
|
}
|
|
|
|
|
2024-05-11 10:09:21 +00:00
|
|
|
// CHECK-LABEL: @non_null_eq
|
2022-10-27 12:40:45 +00:00
|
|
|
#[no_mangle]
|
|
|
|
pub fn non_null_eq(l: Option<NonNull<u8>>, r: Option<NonNull<u8>>) -> bool {
|
|
|
|
// CHECK: start:
|
2023-07-27 21:44:13 +00:00
|
|
|
// CHECK-NEXT: icmp eq ptr
|
2022-10-27 12:40:45 +00:00
|
|
|
// CHECK-NEXT: ret i1
|
|
|
|
l == r
|
|
|
|
}
|
2024-03-05 13:26:47 +00:00
|
|
|
|
2024-05-11 10:09:21 +00:00
|
|
|
// CHECK-LABEL: @ordering_eq
|
2024-03-05 13:26:47 +00:00
|
|
|
#[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,
|
|
|
|
}
|
|
|
|
|
2024-05-11 10:09:21 +00:00
|
|
|
// CHECK-LABEL: @niche_eq
|
2024-03-05 13:26:47 +00:00
|
|
|
#[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
|
2024-05-11 10:09:21 +00:00
|
|
|
// // FIXME-CHECK-LABEL: @bool_eq
|
2024-03-05 13:26:47 +00:00
|
|
|
// #[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
|
|
|
|
// }
|