authorgravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2024-12-26 02:23:21-08:00
committergravatar for david@vortan.devDavid Rubin <david@vortan.dev> 2025-02-25 11:22:33-08:00
logfc776783391b16ef77df05581412746bdb83ffa6
treed4e1370a26e2f3ebf8fbabf2a1087535345d017b
parent95720f007bb0dacc8a7cecb621c322d574c61d00

mem: add `@branchHint` to `indexOfSentinel`

also seems to work around aarch64 LLVM miscompilation :thinking:

1 files changed, 1 insertions(+), 0 deletions(-)

lib/std/mem.zig+1
...@@ -1119,6 +1119,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co...@@ -1119,6 +1119,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
11191119
1120 i += @divExact(std.mem.alignForward(usize, start_addr, block_size) - start_addr, @sizeOf(T));1120 i += @divExact(std.mem.alignForward(usize, start_addr, block_size) - start_addr, @sizeOf(T));
1121 } else {1121 } else {
1122 @branchHint(.unlikely);
1122 // Would read over a page boundary. Per-byte at a time until aligned or found.1123 // Would read over a page boundary. Per-byte at a time until aligned or found.
1123 // 0.39% chance this branch is taken for 4K pages at 16b block length.1124 // 0.39% chance this branch is taken for 4K pages at 16b block length.
1124 //1125 //