about summary refs log tree commit diff
path: root/tests/assembly-llvm/x86_64-cmp.rs
blob: 1f1fe7fd00520809f8f215209824a1d1f3bcae5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//@ 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: sub
    // OPTIM: cmp
    // CHECK: setl
    // CHECK: setg
    // CHECK: sub
    // CHECK: ret
    three_way_compare(a, b)
}

#[no_mangle]
// CHECK-LABEL: unsigned_cmp:
pub fn unsigned_cmp(a: u16, b: u16) -> std::cmp::Ordering {
    // DEBUG: sub
    // OPTIM: cmp
    // CHECK: seta
    // CHECK: sbb
    // CHECK: ret
    three_way_compare(a, b)
}