diff options
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/slice-init.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/codegen/slice-init.rs b/tests/codegen/slice-init.rs index 8126bf84618..a01b432add6 100644 --- a/tests/codegen/slice-init.rs +++ b/tests/codegen/slice-init.rs @@ -63,6 +63,34 @@ pub fn nonzero_integer_array() { opaque(&x); } +const N: usize = 100; + +// FIXME: The two bytes of the u16 are the same, so we should +// just use memset, too. +// CHECK-LABEL: @u16_init_one_bytes +#[no_mangle] +pub fn u16_init_one_bytes() -> [u16; N] { + // CHECK-NOT: select + // CHECK: br + // CHECK-NOT: switch + // CHECK: icmp + // CHECK-NOT: call void @llvm.memset.p0 + [const { u16::from_be_bytes([1, 1]) }; N] +} + +// FIXME: undef bytes can just be initialized with the same value as the +// defined bytes, if the defines bytes are all the same. +// CHECK-LABEL: @option_none_init +#[no_mangle] +pub fn option_none_init() -> [Option<u8>; N] { + // CHECK-NOT: select + // CHECK: br label %repeat_loop_header{{.*}} + // CHECK-NOT: switch + // CHECK: icmp + // CHECK-NOT: call void @llvm.memset.p0 + [None; N] +} + // Use an opaque function to prevent rustc from removing useless drops. #[inline(never)] pub fn opaque(_: impl Sized) {} |
