diff options
Diffstat (limited to 'tests/codegen-llvm/intrinsics/three_way_compare.rs')
| -rw-r--r-- | tests/codegen-llvm/intrinsics/three_way_compare.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/codegen-llvm/intrinsics/three_way_compare.rs b/tests/codegen-llvm/intrinsics/three_way_compare.rs new file mode 100644 index 00000000000..95fcb636f7c --- /dev/null +++ b/tests/codegen-llvm/intrinsics/three_way_compare.rs @@ -0,0 +1,28 @@ +//@ revisions: DEBUG OPTIM +//@ [DEBUG] compile-flags: -C opt-level=0 +//@ [OPTIM] compile-flags: -C opt-level=3 +//@ compile-flags: -C no-prepopulate-passes +//@ min-llvm-version: 20 + +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +use std::intrinsics::three_way_compare; + +#[no_mangle] +// CHECK-LABEL: @signed_cmp +// CHECK-SAME: (i16{{.*}} %a, i16{{.*}} %b) +pub fn signed_cmp(a: i16, b: i16) -> std::cmp::Ordering { + // CHECK: %[[CMP:.+]] = call i8 @llvm.scmp.i8.i16(i16 %a, i16 %b) + // CHECK-NEXT: ret i8 %[[CMP]] + three_way_compare(a, b) +} + +#[no_mangle] +// CHECK-LABEL: @unsigned_cmp +// CHECK-SAME: (i16{{.*}} %a, i16{{.*}} %b) +pub fn unsigned_cmp(a: u16, b: u16) -> std::cmp::Ordering { + // CHECK: %[[CMP:.+]] = call i8 @llvm.ucmp.i8.i16(i16 %a, i16 %b) + // CHECK-NEXT: ret i8 %[[CMP]] + three_way_compare(a, b) +} |
