@@ -48,16 +48,32 @@ pub fn swap_rgba64(x: &mut RGBA64, y: &mut RGBA64) {
48
48
swap ( x, y)
49
49
}
50
50
51
+ // CHECK-LABEL: @swap_vecs
52
+ #[ no_mangle]
53
+ pub fn swap_vecs ( x : & mut Vec < u32 > , y : & mut Vec < u32 > ) {
54
+ // CHECK-NOT: alloca
55
+ // CHECK: ret void
56
+ swap ( x, y)
57
+ }
58
+
59
+ // CHECK-LABEL: @swap_slices
60
+ #[ no_mangle]
61
+ pub fn swap_slices < ' a > ( x : & mut & ' a [ u32 ] , y : & mut & ' a [ u32 ] ) {
62
+ // CHECK-NOT: alloca
63
+ // CHECK: ret void
64
+ swap ( x, y)
65
+ }
66
+
51
67
// LLVM doesn't vectorize a loop over 3-byte elements,
52
68
// so we chunk it down to bytes and loop over those instead.
53
69
type RGB24 = [ u8 ; 3 ] ;
54
70
55
71
// CHECK-LABEL: @swap_rgb24_slices
56
72
#[ no_mangle]
57
73
pub fn swap_rgb24_slices ( x : & mut [ RGB24 ] , y : & mut [ RGB24 ] ) {
58
- // CHECK-NOT: alloca
59
- // CHECK: load <{{[0-9]+}} x i8>
60
- // CHECK: store <{{[0-9]+}} x i8>
74
+ // CHECK-NOT: alloca
75
+ // CHECK: load <{{[0-9]+}} x i8>
76
+ // CHECK: store <{{[0-9]+}} x i8>
61
77
if x. len ( ) == y. len ( ) {
62
78
x. swap_with_slice ( y) ;
63
79
}
@@ -69,9 +85,9 @@ type RGBA32 = [u8; 4];
69
85
// CHECK-LABEL: @swap_rgba32_slices
70
86
#[ no_mangle]
71
87
pub fn swap_rgba32_slices ( x : & mut [ RGBA32 ] , y : & mut [ RGBA32 ] ) {
72
- // CHECK-NOT: alloca
73
- // CHECK: load <{{[0-9]+}} x i32>
74
- // CHECK: store <{{[0-9]+}} x i32>
88
+ // CHECK-NOT: alloca
89
+ // CHECK: load <{{[0-9]+}} x i32>
90
+ // CHECK: store <{{[0-9]+}} x i32>
75
91
if x. len ( ) == y. len ( ) {
76
92
x. swap_with_slice ( y) ;
77
93
}
@@ -84,10 +100,24 @@ const _: () = assert!(!std::mem::size_of::<String>().is_power_of_two());
84
100
// CHECK-LABEL: @swap_string_slices
85
101
#[ no_mangle]
86
102
pub fn swap_string_slices ( x : & mut [ String ] , y : & mut [ String ] ) {
87
- // CHECK-NOT: alloca
88
- // CHECK: load <{{[0-9]+}} x i64>
89
- // CHECK: store <{{[0-9]+}} x i64>
103
+ // CHECK-NOT: alloca
104
+ // CHECK: load <{{[0-9]+}} x i64>
105
+ // CHECK: store <{{[0-9]+}} x i64>
90
106
if x. len ( ) == y. len ( ) {
91
107
x. swap_with_slice ( y) ;
92
108
}
93
109
}
110
+
111
+ #[ repr( C , packed) ]
112
+ pub struct Packed {
113
+ pub first : bool ,
114
+ pub second : usize ,
115
+ }
116
+
117
+ // CHECK-LABEL: @swap_packed_structs
118
+ #[ no_mangle]
119
+ pub fn swap_packed_structs ( x : & mut Packed , y : & mut Packed ) {
120
+ // CHECK-NOT: alloca
121
+ // CHECK: ret void
122
+ swap ( x, y)
123
+ }
0 commit comments