diff options
| author | The 8472 <git@infinite-source.de> | 2023-08-25 23:29:18 +0200 |
|---|---|---|
| committer | The 8472 <git@infinite-source.de> | 2023-08-27 15:32:34 +0200 |
| commit | 72b01d5cca0604e1ea5818d90b9feefae92a0093 (patch) | |
| tree | 21c2385cc0f480d811a0a0d8e56e186626f1382d /tests/codegen/lib-optimizations/iter-sum.rs | |
| parent | f320f42c593b4353ea47448805f009ca0646cb06 (diff) | |
| download | rust-72b01d5cca0604e1ea5818d90b9feefae92a0093.tar.gz rust-72b01d5cca0604e1ea5818d90b9feefae92a0093.zip | |
Optimize Take::{fold, for_each} when wrapping TrustedRandomAccess iterators
Diffstat (limited to 'tests/codegen/lib-optimizations/iter-sum.rs')
| -rw-r--r-- | tests/codegen/lib-optimizations/iter-sum.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/codegen/lib-optimizations/iter-sum.rs b/tests/codegen/lib-optimizations/iter-sum.rs new file mode 100644 index 00000000000..d6ea4cd74d5 --- /dev/null +++ b/tests/codegen/lib-optimizations/iter-sum.rs @@ -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() +} |
