Skip to content

Commit

Permalink
compiler-rt: simplify aligned memcpy loop
Browse files Browse the repository at this point in the history
This change removes a few instruction from the aligned hot loop by not
updating the remaining size.
  • Loading branch information
dweiller committed Feb 13, 2024
1 parent bcca03b commit 4cd6690
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/compiler_rt/memcpy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,13 @@ inline fn memcpy_aligned(
) void {
@setRuntimeSafety(false);

var d = dest;
var s = src;
var n = len;
var i: usize = 0;

while (n >= size) {
d[0] = s[0];
n -= size;
d += 1;
s += 1;
while (i < len / size) : (i += 1) {
dest[i] = src[i];
}

memcpy_remainder(size, @ptrCast(d), @ptrCast(s), n);
memcpy_remainder(size, @ptrCast(dest + i), @ptrCast(src + i), len % size);
}

inline fn memcpy_remainder(
Expand Down

0 comments on commit 4cd6690

Please sign in to comment.