about summary refs log tree commit diff
path: root/tests/codegen-llvm/lib-optimizations/iter-sum.rs
blob: a054ffffe74bd41f69f88bb7d3be1f391c11e5a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
//@ compile-flags: -Copt-level=3
//@ only-x86_64 (vectorization varies between architectures)
#![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()
}