-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor memchr to allow optimization
- Loading branch information
Showing
2 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This test checks that the call to memchr is optimized away when searching in small slices. | ||
|
||
// compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
type T = u8; | ||
|
||
// CHECK-LABEL: @foo1 | ||
#[no_mangle] | ||
pub fn foo1(x: T, data: &[T; 1]) -> bool { | ||
// CHECK-NOT: memchr | ||
data.contains(&x) | ||
} | ||
|
||
// CHECK-LABEL: @foo2 | ||
#[no_mangle] | ||
pub fn foo2(x: T, data: &[T; 2]) -> bool { | ||
// CHECK-NOT: memchr | ||
data.contains(&x) | ||
} | ||
|
||
// CHECK-LABEL: @foo3 | ||
#[no_mangle] | ||
pub fn foo3(x: T, data: &[T; 3]) -> bool { | ||
// CHECK-NOT: memchr | ||
data.contains(&x) | ||
} | ||
|
||
// CHECK-LABEL: @foo4 | ||
#[no_mangle] | ||
pub fn foo4(x: T, data: &[T; 4]) -> bool { | ||
// CHECK-NOT: memchr | ||
data.contains(&x) | ||
} | ||
|
||
// CHECK-LABEL: @foo16 | ||
#[no_mangle] | ||
pub fn foo16(x: T, data: &[T; 16]) -> bool { | ||
// CHECK-NOT: memchr | ||
data.contains(&x) | ||
} |