From fc776783391b16ef77df05581412746bdb83ffa6 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Thu, 26 Dec 2024 02:23:21 -0800 Subject: [PATCH] mem: add `@branchHint` to `indexOfSentinel` also seems to work around aarch64 LLVM miscompilation :thinking: --- lib/std/mem.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/std/mem.zig b/lib/std/mem.zig index be1153935a..0fa7deadc3 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1119,6 +1119,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co i += @divExact(std.mem.alignForward(usize, start_addr, block_size) - start_addr, @sizeOf(T)); } else { + @branchHint(.unlikely); // Would read over a page boundary. Per-byte at a time until aligned or found. // 0.39% chance this branch is taken for 4K pages at 16b block length. //