blob: 84a1f713ce68ca2cd08d5bbeac2f0095cedfe0eb [file]
//@ compile-flags: -Copt-level=3 -C no-prepopulate-passes
//@ only-64bit (so I don't need to worry about usize)
#![crate_type = "lib"]
#![feature(core_intrinsics)]
// This deals in a count of elements, not bytes, so we need to multiply.
// Ensure we preserve UB from a count too high to be valid.
use std::intrinsics::copy_nonoverlapping;
// CHECK-LABEL: @copy_u16(
#[no_mangle]
pub unsafe fn copy_u16(src: *const u16, dst: *mut u16, count: usize) {
// CHECK: [[BYTES:%.+]] = mul nuw nsw i64 %count, 2
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 2 %dst, ptr align 2 %src, i64 [[BYTES]], i1 false)
copy_nonoverlapping(src, dst, count)
}