summaryrefslogtreecommitdiffstats
path: root/tests/codegen/issue-75659.rs
blob: 9394868c08db51995ea1bde2472fec0f0673c554 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This test checks that the call to memchr/slice_contains is optimized away
// when searching in small slices.

// compile-flags: -O -Zinline-mir=false
// only-x86_64

#![crate_type = "lib"]

// CHECK-LABEL: @foo1
#[no_mangle]
pub fn foo1(x: u8, data: &[u8; 1]) -> bool {
    // CHECK-NOT: memchr
    // CHECK-NOT: slice_contains
    data.contains(&x)
}

// CHECK-LABEL: @foo2
#[no_mangle]
pub fn foo2(x: u8, data: &[u8; 2]) -> bool {
    // CHECK-NOT: memchr
    // CHECK-NOT: slice_contains
    data.contains(&x)
}

// CHECK-LABEL: @foo3
#[no_mangle]
pub fn foo3(x: u8, data: &[u8; 3]) -> bool {
    // CHECK-NOT: memchr
    // CHECK-NOT: slice_contains
    data.contains(&x)
}

// CHECK-LABEL: @foo4
#[no_mangle]
pub fn foo4(x: u8, data: &[u8; 4]) -> bool {
    // CHECK-NOT: memchr
    // CHECK-NOT: slice_contains
    data.contains(&x)
}

// CHECK-LABEL: @foo8
#[no_mangle]
pub fn foo8(x: u8, data: &[u8; 8]) -> bool {
    // CHECK-NOT: memchr
    // CHECK-NOT: slice_contains
    data.contains(&x)
}

// CHECK-LABEL: @foo8_i8
#[no_mangle]
pub fn foo8_i8(x: i8, data: &[i8; 8]) -> bool {
    // CHECK-NOT: memchr
    // CHECK-NOT: slice_contains
    !data.contains(&x)
}

// Check that the general case isn't inlined
// CHECK-LABEL: @foo80
#[no_mangle]
pub fn foo80(x: u8, data: &[u8; 80]) -> bool {
    // CHECK: call core::slice::memchr
    data.contains(&x)
}