rust/tests/assembly/x86_64-cmp.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.0 KiB
Rust
Raw Normal View History

2023-03-05 22:19:41 -06:00
//@ revisions: DEBUG OPTIM
//@ [DEBUG] compile-flags: -C opt-level=0
//@ [OPTIM] compile-flags: -C opt-level=3
//@ assembly-output: emit-asm
//@ compile-flags: --crate-type=lib -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64
//@ ignore-sgx
#![feature(core_intrinsics)]
use std::intrinsics::three_way_compare;
#[no_mangle]
// CHECK-LABEL: signed_cmp:
pub fn signed_cmp(a: i16, b: i16) -> std::cmp::Ordering {
// DEBUG: cmp
// DEBUG: setg
// DEBUG: and
// DEBUG: cmp
// DEBUG: setl
// DEBUG: and
// DEBUG: sub
// OPTIM: xor
// OPTIM: cmp
// OPTIM: setne
// OPTIM: mov
// OPTIM: cmovge
// OPTIM: ret
three_way_compare(a, b)
}
#[no_mangle]
// CHECK-LABEL: unsigned_cmp:
pub fn unsigned_cmp(a: u16, b: u16) -> std::cmp::Ordering {
// DEBUG: cmp
// DEBUG: seta
// DEBUG: and
// DEBUG: cmp
// DEBUG: setb
// DEBUG: and
// DEBUG: sub
// OPTIM: xor
// OPTIM: cmp
// OPTIM: setne
// OPTIM: mov
// OPTIM: cmovae
// OPTIM: ret
three_way_compare(a, b)
}