Skip to content

Commit

Permalink
compiler-rt: simplify release small memcpy
Browse files Browse the repository at this point in the history
This change produces 2 fewer bytes of code but adds an unconditional
jump to the copy loop. On znver4/5 the previous implementation produced
significantly mode code (using LLVM 19).
  • Loading branch information
dweiller committed Jan 17, 2025
1 parent a041494 commit 48b28db
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/compiler_rt/memcpy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ comptime {
fn memcpySmall(noalias dest: ?[*]u8, noalias src: ?[*]const u8, len: usize) callconv(.C) ?[*]u8 {
@setRuntimeSafety(builtin.is_test);

if (len != 0) {
var i: usize = 0;
while (true) {
dest.?[i] = src.?[i];
i += 1;
if (i == len) break;
}
for (0..len) |i| {
dest.?[i] = src.?[i];
}

return dest;
Expand Down

0 comments on commit 48b28db

Please sign in to comment.