-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #115273 - the8472:take-fold, r=cuviper
Optimize Take::{fold, for_each} when wrapping TrustedRandomAccess iterators
- Loading branch information
Showing
2 changed files
with
97 additions
and
19 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,15 @@ | ||
// ignore-debug: the debug assertions get in the way | ||
// compile-flags: -O | ||
// 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() | ||
} |