about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2022-05-01 00:16:16 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2022-05-01 22:28:11 -0700
commit2830dbd64f50b4a8025025f01578e45cbf9d3719 (patch)
tree3f673bd79d8b9645a36c6615eaf781dfd6139448 /src/test/codegen
parent61469b682c2b0bf9cebc4622f1859e2bb3b7ebca (diff)
downloadrust-2830dbd64f50b4a8025025f01578e45cbf9d3719.tar.gz
rust-2830dbd64f50b4a8025025f01578e45cbf9d3719.zip
Tweak the calloc optimization to only apply to shortish-arrays
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/vec-calloc.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/test/codegen/vec-calloc.rs b/src/test/codegen/vec-calloc.rs
new file mode 100644
index 00000000000..c616e9f1145
--- /dev/null
+++ b/src/test/codegen/vec-calloc.rs
@@ -0,0 +1,32 @@
+// compile-flags: -O
+// only-x86_64
+// ignore-debug
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: @vec_zero_scalar
+#[no_mangle]
+pub fn vec_zero_scalar(n: usize) -> Vec<i32> {
+    // CHECK-NOT: __rust_alloc(
+    // CHECK: __rust_alloc_zeroed(
+    // CHECK-NOT: __rust_alloc(
+    vec![0; n]
+}
+
+// CHECK-LABEL: @vec_zero_rgb48
+#[no_mangle]
+pub fn vec_zero_rgb48(n: usize) -> Vec<[u16; 3]> {
+    // CHECK-NOT: __rust_alloc(
+    // CHECK: __rust_alloc_zeroed(
+    // CHECK-NOT: __rust_alloc(
+    vec![[0, 0, 0]; n]
+}
+
+// CHECK-LABEL: @vec_zero_array_32
+#[no_mangle]
+pub fn vec_zero_array_32(n: usize) -> Vec<[i64; 32]> {
+    // CHECK-NOT: __rust_alloc(
+    // CHECK: __rust_alloc_zeroed(
+    // CHECK-NOT: __rust_alloc(
+    vec![[0_i64; 32]; n]
+}