| Issue |
237927
|
| Summary |
[AArch64] Repeated base-pointer load and end-address calculation inside a loop
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
bagrorg
|
Clang computes an array’s end pointer before entering a loop, but then reloads the base pointer and recomputes `base + count * 4` on each iteration. GCC retains the end pointer in a register and compares the advancing cursor directly against it.
[Reproducer on Compiler Explorer](https://godbolt.org/z/Y7Wh39The): includes C++ source and saved **original** and **patched** Clang assembly. The patched assembly follows GCC’s end-pointer reuse, removing the repeated load and address calculation.
Tested configuration:
- **Clang:** 24.0.0git, LLVM `cd3be30dcbabdf92067782b62dd5f3d995fd5d23`
- **GCC:** 16.0.1 20260322, `r16-8246-g569ace1fa50`
- **Hardware/OS:** Neoverse V3, Linux AArch64
- **Flags:** `-O3 -DNDEBUG -std=c++17 -mcpu=neoverse-v3`
Measurements:
| Original Clang | Patched Clang | GCC |
|---:|---:|---:|
| 0.4381 ns/token | 0.4081 ns/token | 0.3722 ns/token |
Originally observed in [simdjson’s token-skipping loop](https://github.com/simdjson/simdjson/blob/3b2870d822b1797cfebb368cd76df0413a7016bb/include/simdjson/generic/ondemand/json_iterator-inl.h#L164-L178), revision `3b2870d822b1797cfebb368cd76df0413a7016bb`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs