about summary refs log tree commit diff
path: root/tests/codegen-llvm/lib-optimizations/slice_rotate.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codegen-llvm/lib-optimizations/slice_rotate.rs')
-rw-r--r--tests/codegen-llvm/lib-optimizations/slice_rotate.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/codegen-llvm/lib-optimizations/slice_rotate.rs b/tests/codegen-llvm/lib-optimizations/slice_rotate.rs
new file mode 100644
index 00000000000..aa4bb3b528c
--- /dev/null
+++ b/tests/codegen-llvm/lib-optimizations/slice_rotate.rs
@@ -0,0 +1,30 @@
+//@ compile-flags: -Copt-level=3
+
+#![crate_type = "lib"]
+
+// Ensure that the simple case of rotating by a constant 1 optimizes to the obvious thing
+
+// CHECK-LABEL: @rotate_left_by_one
+#[no_mangle]
+pub fn rotate_left_by_one(slice: &mut [i32]) {
+    // CHECK-NOT: phi
+    // CHECK-NOT: call
+    // CHECK-NOT: load
+    // CHECK-NOT: store
+    // CHECK-NOT: getelementptr
+    // CHECK: %[[END:.+]] = getelementptr
+    // CHECK-NEXT: %[[DIM:.+]] = getelementptr
+    // CHECK-NEXT: %[[LAST:.+]] = load
+    // CHECK-NEXT: %[[FIRST:.+]] = shl
+    // CHECK-NEXT: call void @llvm.memmove
+    // CHECK-NEXT: store i32 %[[LAST]], ptr %[[DIM:.+]]
+    // CHECK-NOT: phi
+    // CHECK-NOT: call
+    // CHECK-NOT: load
+    // CHECK-NOT: store
+    // CHECK-NOT: getelementptr
+    // CHECK: ret void
+    if !slice.is_empty() {
+        slice.rotate_left(1);
+    }
+}