Add a codegen test for manually swapping a small Copy
type
To confirm we're not just helping `mem::swap`
This commit is contained in:
parent
9eee230cd0
commit
cce0b52e7b
@ -8,10 +8,30 @@
|
||||
|
||||
type RGB48 = [u16; 3];
|
||||
|
||||
// CHECK-LABEL: @swap_rgb48_manually(
|
||||
#[no_mangle]
|
||||
pub fn swap_rgb48_manually(x: &mut RGB48, y: &mut RGB48) {
|
||||
// CHECK-NOT: alloca
|
||||
// CHECK: %temp = alloca [3 x i16]
|
||||
// CHECK-NOT: alloca
|
||||
// CHECK-NOT: call void @llvm.memcpy
|
||||
// CHECK: call void @llvm.memcpy.{{.+}}({{.+}} %temp, {{.+}} %x, {{.+}} 6, {{.+}})
|
||||
// CHECK: call void @llvm.memcpy.{{.+}}({{.+}} %x, {{.+}} %y, {{.+}} 6, {{.+}})
|
||||
// CHECK: call void @llvm.memcpy.{{.+}}({{.+}} %y, {{.+}} %temp, {{.+}} 6, {{.+}})
|
||||
// CHECK-NOT: call void @llvm.memcpy
|
||||
|
||||
let temp = *x;
|
||||
*x = *y;
|
||||
*y = temp;
|
||||
}
|
||||
|
||||
// CHECK-LABEL: @swap_rgb48
|
||||
#[no_mangle]
|
||||
pub fn swap_rgb48(x: &mut RGB48, y: &mut RGB48) {
|
||||
// FIXME MIR inlining messes up LLVM optimizations.
|
||||
// If these checks start failing, please update this test.
|
||||
// CHECK: alloca [3 x i16]
|
||||
// CHECK: call void @llvm.memcpy
|
||||
// WOULD-CHECK-NOT: alloca
|
||||
// WOULD-CHECK: load i48
|
||||
// WOULD-CHECK: store i48
|
||||
|
Loading…
Reference in New Issue
Block a user