mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
b5376ba601
I added this back in 111999, but I no longer think it's a good idea - It had to get scaled back to only power-of-two things to not break a bunch of targets - LLVM seems to be getting better at memcpy removal anyway - Introducing vector instructions has seemed to sometimes (115515) make autovectorization worse So this removes it from the codegen crates entirely, and instead just tries to use <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/traits/builder/trait.BuilderMethods.html#method.typed_place_copy> instead of direct `memcpy` so things will still use load/store for immediates.
34 lines
876 B
Rust
34 lines
876 B
Rust
//@ compile-flags: -O
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
// CHECK-LABEL: @array_copy_1_element
|
|
#[no_mangle]
|
|
pub fn array_copy_1_element(a: &[u8; 1], p: &mut [u8; 1]) {
|
|
// CHECK-NOT: alloca
|
|
// CHECK: %[[TEMP:.+]] = load i8, ptr %a, align 1
|
|
// CHECK: store i8 %[[TEMP]], ptr %p, align 1
|
|
// CHECK: ret
|
|
*p = *a;
|
|
}
|
|
|
|
// CHECK-LABEL: @array_copy_2_elements
|
|
#[no_mangle]
|
|
pub fn array_copy_2_elements(a: &[u8; 2], p: &mut [u8; 2]) {
|
|
// CHECK-NOT: alloca
|
|
// CHECK: %[[TEMP:.+]] = load i16, ptr %a, align 1
|
|
// CHECK: store i16 %[[TEMP]], ptr %p, align 1
|
|
// CHECK: ret
|
|
*p = *a;
|
|
}
|
|
|
|
// CHECK-LABEL: @array_copy_4_elements
|
|
#[no_mangle]
|
|
pub fn array_copy_4_elements(a: &[u8; 4], p: &mut [u8; 4]) {
|
|
// CHECK-NOT: alloca
|
|
// CHECK: %[[TEMP:.+]] = load i32, ptr %a, align 1
|
|
// CHECK: store i32 %[[TEMP]], ptr %p, align 1
|
|
// CHECK: ret
|
|
*p = *a;
|
|
}
|