2023-08-25 16:29:18 -05:00
|
|
|
//@ compile-flags: -O
|
2023-09-02 06:42:58 -05:00
|
|
|
//@ only-x86_64 (vectorization varies between architectures)
|
2023-08-25 16:29:18 -05:00
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
// Ensure that slice + take + sum gets vectorized.
|
|
|
|
// Currently this relies on the slice::Iter::try_fold implementation
|
|
|
|
// CHECK-LABEL: @slice_take_sum
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn slice_take_sum(s: &[u64], l: usize) -> u64 {
|
|
|
|
// CHECK: vector.body:
|
|
|
|
// CHECK: ret
|
|
|
|
s.iter().take(l).sum()
|
|
|
|
}
|