about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2020-11-06 13:51:44 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2021-01-15 21:24:38 -0800
commitae4b5a21e62fe30a924c45e2734880c4de844446 (patch)
tree55a4ec0ac1e24477ee364ee40352d8c98aaa4670 /src/test/codegen
parent6c869d34ae2d87d21db9892d4dc088639bcbe041 (diff)
downloadrust-ae4b5a21e62fe30a924c45e2734880c4de844446.tar.gz
rust-ae4b5a21e62fe30a924c45e2734880c4de844446.zip
Add `as_rchunks` (and friends) to slices
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/slice-as_chunks.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/codegen/slice-as_chunks.rs b/src/test/codegen/slice-as_chunks.rs
new file mode 100644
index 00000000000..7b857879eea
--- /dev/null
+++ b/src/test/codegen/slice-as_chunks.rs
@@ -0,0 +1,32 @@
+// no-system-llvm
+// compile-flags: -O
+// only-64bit (because the LLVM type of i64 for usize shows up)
+
+#![crate_type = "lib"]
+#![feature(slice_as_chunks)]
+
+// CHECK-LABEL: @chunks4
+#[no_mangle]
+pub fn chunks4(x: &[u8]) -> &[[u8; 4]] {
+    // CHECK-NEXT: start:
+    // CHECK-NEXT: lshr i64 %x.1, 2
+    // CHECK-NOT: shl
+    // CHECK-NOT: mul
+    // CHECK-NOT: udiv
+    // CHECK-NOT: urem
+    // CHECK: ret
+    x.as_chunks().0
+}
+
+// CHECK-LABEL: @chunks4_with_remainder
+#[no_mangle]
+pub fn chunks4_with_remainder(x: &[u8]) -> (&[[u8; 4]], &[u8]) {
+    // CHECK: and i64 %x.1, -4
+    // CHECK: and i64 %x.1, 3
+    // CHECK: lshr exact
+    // CHECK-NOT: mul
+    // CHECK-NOT: udiv
+    // CHECK-NOT: urem
+    // CHECK: ret
+    x.as_chunks()
+}