summaryrefslogtreecommitdiffstats
path: root/tests/codegen/intrinsics/unchecked_math.rs
blob: 419c120ede9eccdb1ac12cf8b90d25c2bf282991 (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
35
36
37
38
39
40
41
42
43
44
45
46
#![crate_type = "lib"]
#![feature(core_intrinsics)]

use std::intrinsics::*;

// CHECK-LABEL: @unchecked_add_signed
#[no_mangle]
pub unsafe fn unchecked_add_signed(a: i32, b: i32) -> i32 {
    // CHECK: add nsw
    unchecked_add(a, b)
}

// CHECK-LABEL: @unchecked_add_unsigned
#[no_mangle]
pub unsafe fn unchecked_add_unsigned(a: u32, b: u32) -> u32 {
    // CHECK: add nuw
    unchecked_add(a, b)
}

// CHECK-LABEL: @unchecked_sub_signed
#[no_mangle]
pub unsafe fn unchecked_sub_signed(a: i32, b: i32) -> i32 {
    // CHECK: sub nsw
    unchecked_sub(a, b)
}

// CHECK-LABEL: @unchecked_sub_unsigned
#[no_mangle]
pub unsafe fn unchecked_sub_unsigned(a: u32, b: u32) -> u32 {
    // CHECK: sub nuw
    unchecked_sub(a, b)
}

// CHECK-LABEL: @unchecked_mul_signed
#[no_mangle]
pub unsafe fn unchecked_mul_signed(a: i32, b: i32) -> i32 {
    // CHECK: mul nsw
    unchecked_mul(a, b)
}

// CHECK-LABEL: @unchecked_mul_unsigned
#[no_mangle]
pub unsafe fn unchecked_mul_unsigned(a: u32, b: u32) -> u32 {
    // CHECK: mul nuw
    unchecked_mul(a, b)
}