about summary refs log tree commit diff
path: root/tests/codegen/array-codegen.rs
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2023-10-06 01:17:09 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2023-10-07 00:10:32 -0700
commitae9cec58394d7a38aac17e2873d213d5fcd85f7a (patch)
tree694b6a4b46ac6aefff6c1c6e85478270ea0ffa0b /tests/codegen/array-codegen.rs
parent579be69de9f98f56d92b93820eaf7e6b06b517a5 (diff)
downloadrust-ae9cec58394d7a38aac17e2873d213d5fcd85f7a.tar.gz
rust-ae9cec58394d7a38aac17e2873d213d5fcd85f7a.zip
Copy 1-element arrays as scalars, not vectors
For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`.
Diffstat (limited to 'tests/codegen/array-codegen.rs')
-rw-r--r--tests/codegen/array-codegen.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/codegen/array-codegen.rs b/tests/codegen/array-codegen.rs
index ba0d444f97e..bf5ae74679b 100644
--- a/tests/codegen/array-codegen.rs
+++ b/tests/codegen/array-codegen.rs
@@ -32,3 +32,25 @@ pub fn array_copy(a: &[u8; 4], p: &mut [u8; 4]) {
     // CHECK: store <4 x i8> %[[TEMP2]], ptr %p, align 1
     *p = *a;
 }
+
+// CHECK-LABEL: @array_copy_1_element
+#[no_mangle]
+pub fn array_copy_1_element(a: &[u8; 1], p: &mut [u8; 1]) {
+    // CHECK: %[[LOCAL:.+]] = alloca [1 x i8], align 1
+    // CHECK: %[[TEMP1:.+]] = load i8, ptr %a, align 1
+    // CHECK: store i8 %[[TEMP1]], ptr %[[LOCAL]], align 1
+    // CHECK: %[[TEMP2:.+]] = load i8, ptr %[[LOCAL]], align 1
+    // CHECK: store i8 %[[TEMP2]], ptr %p, align 1
+    *p = *a;
+}
+
+// CHECK-LABEL: @array_copy_2_elements
+#[no_mangle]
+pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) {
+    // CHECK: %[[LOCAL:.+]] = alloca [2 x i8], align 1
+    // CHECK: %[[TEMP1:.+]] = load <2 x i8>, ptr %a, align 1
+    // CHECK: store <2 x i8> %[[TEMP1]], ptr %[[LOCAL]], align 1
+    // CHECK: %[[TEMP2:.+]] = load <2 x i8>, ptr %[[LOCAL]], align 1
+    // CHECK: store <2 x i8> %[[TEMP2]], ptr %p, align 1
+    *p = *a;
+}