| ... | @@ -203,7 +203,11 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -203,7 +203,11 @@ pub fn MultiArrayList(comptime S: type) type { |
| 203 | const other_slice = other.slice(); | 203 | const other_slice = other.slice(); |
| 204 | inline for (fields) |field_info, i| { | 204 | inline for (fields) |field_info, i| { |
| 205 | const field = @intToEnum(Field, i); | 205 | const field = @intToEnum(Field, i); |
| 206 | mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field)); | 206 | // TODO we should be able to use std.mem.copy here but it causes a |
| | 207 | // test failure on aarch64 with -OReleaseFast |
| | 208 | const src_slice = mem.sliceAsBytes(self_slice.items(field)); |
| | 209 | const dst_slice = mem.sliceAsBytes(other_slice.items(field)); |
| | 210 | @memcpy(dst_slice.ptr, src_slice.ptr, src_slice.len); |
| 207 | } | 211 | } |
| 208 | gpa.free(self.allocatedBytes()); | 212 | gpa.free(self.allocatedBytes()); |
| 209 | self.* = other; | 213 | self.* = other; |
| ... | @@ -256,25 +260,20 @@ pub fn MultiArrayList(comptime S: type) type { | ... | @@ -256,25 +260,20 @@ pub fn MultiArrayList(comptime S: type) type { |
| 256 | const other_slice = other.slice(); | 260 | const other_slice = other.slice(); |
| 257 | inline for (fields) |field_info, i| { | 261 | inline for (fields) |field_info, i| { |
| 258 | const field = @intToEnum(Field, i); | 262 | const field = @intToEnum(Field, i); |
| 259 | mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field)); | 263 | // TODO we should be able to use std.mem.copy here but it causes a |
| | 264 | // test failure on aarch64 with -OReleaseFast |
| | 265 | const src_slice = mem.sliceAsBytes(self_slice.items(field)); |
| | 266 | const dst_slice = mem.sliceAsBytes(other_slice.items(field)); |
| | 267 | @memcpy(dst_slice.ptr, src_slice.ptr, src_slice.len); |
| 260 | } | 268 | } |
| 261 | gpa.free(self.allocatedBytes()); | 269 | gpa.free(self.allocatedBytes()); |
| 262 | self.* = other; | 270 | self.* = other; |
| 263 | } | 271 | } |
| 264 | | 272 | |
| 265 | fn capacityInBytes(capacity: usize) usize { | 273 | fn capacityInBytes(capacity: usize) usize { |
| 266 | // TODO move this workaround of LLVM SIMD bugs into the Zig frontend. | 274 | const sizes_vector: std.meta.Vector(sizes.bytes.len, usize) = sizes.bytes; |
| 267 | if (std.Target.current.cpu.arch == .aarch64) { | 275 | const capacity_vector = @splat(sizes.bytes.len, capacity); |
| 268 | var sum: usize = 0; | 276 | return @reduce(.Add, capacity_vector * sizes_vector); |
| 269 | for (sizes.bytes) |size| { | | |
| 270 | sum += capacity * size; | | |
| 271 | } | | |
| 272 | return sum; | | |
| 273 | } else { | | |
| 274 | const sizes_vector: std.meta.Vector(sizes.bytes.len, usize) = sizes.bytes; | | |
| 275 | const capacity_vector = @splat(sizes.bytes.len, capacity); | | |
| 276 | return @reduce(.Add, capacity_vector * sizes_vector); | | |
| 277 | } | | |
| 278 | } | 277 | } |
| 279 | | 278 | |
| 280 | fn allocatedBytes(self: Self) []align(@alignOf(S)) u8 { | 279 | fn allocatedBytes(self: Self) []align(@alignOf(S)) u8 { |