Optimize Take::{fold, for_each} when wrapping TrustedRandomAccess iterators
This commit is contained in:
parent
f320f42c59
commit
72b01d5cca
2 changed files with 97 additions and 19 deletions
14
tests/codegen/lib-optimizations/iter-sum.rs
Normal file
14
tests/codegen/lib-optimizations/iter-sum.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// ignore-debug: the debug assertions get in the way
|
||||
// compile-flags: -O
|
||||
#![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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue