| Issue |
237931
|
| Summary |
[AArch64] Stores remain inside a loop despite values already being held in registers
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
bagrorg
|
Clang updates a pointer and counter in registers but also stores both into the result object on every iteration. GCC keeps the updates in registers and stores the final values when the loop exits.
[Reproducer on Compiler Explorer](https://godbolt.org/z/j97cT71bj): includes C++ source and **original and patched Clang-generated assembly**. The patched assembly follows GCC’s store placement, moving the two stores to the loop exit while preserving the existing calculations.
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:
| Clang — original assembly | Clang — patched assembly | GCC |
|---:|---:|---:|
| 0.6877 ns/token | 0.6728 ns/token | 0.6518 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-L186), revision `3b2870d822b1797cfebb368cd76df0413a7016bb`.
This assembly change reduced elapsed time by **1.15–4.72%** in affected simdjson benchmarks.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs