about summary refs log tree commit diff
path: root/tests/codegen/lib-optimizations
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-03 09:28:31 +0200
committerRalf Jung <post@ralfj.de>2023-09-03 09:28:31 +0200
commitfb26c21c356075c0cd35d98fa0b786b7633249d8 (patch)
tree62acd3e15506a4b53b29a70b7882c0c2fa0352b4 /tests/codegen/lib-optimizations
parentdc81d6c2827bb23e75f1dc6c42e9c705ed976ba1 (diff)
parenta989e25f1b87949a886eab3da10324d14189fe95 (diff)
downloadrust-fb26c21c356075c0cd35d98fa0b786b7633249d8.tar.gz
rust-fb26c21c356075c0cd35d98fa0b786b7633249d8.zip
Merge from rustc
Diffstat (limited to 'tests/codegen/lib-optimizations')
-rw-r--r--tests/codegen/lib-optimizations/iter-sum.rs15
1 files changed, 15 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..ff7ca6ef6c1
--- /dev/null
+++ b/tests/codegen/lib-optimizations/iter-sum.rs
@@ -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()
+}