Specialize array cloning for Copy types

Because after PR 86041, the optimizer no longer load-merges at the LLVM IR level, which might be part of the perf loss.  (I'll run perf and see if this makes a difference.)

Also I added a codegen test so this hopefully won't regress in future -- it passes on stable and with my change here, but not on the 2021-11-09 nightly.
This commit is contained in:
Scott McMurray 2021-11-09 21:43:20 -08:00
parent 8b09ba6a5d
commit cc7d8014d7
2 changed files with 37 additions and 3 deletions

View file

@ -0,0 +1,15 @@
// compile-flags: -O
#![crate_type = "lib"]
// CHECK-LABEL: @array_clone
#[no_mangle]
pub fn array_clone(a: &[u8; 2]) -> [u8; 2] {
// CHECK-NOT: getelementptr
// CHECK-NOT: load i8
// CHECK-NOT: zext
// CHECK-NOT: shl
// CHECK: load i16
// CHECK-NEXT: ret i16
a.clone()
}