| Issue |
237994
|
| Summary |
[AArch64] Redundant address reconstruction instead of reusing an available pointer
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
bagrorg
|
Clang reconstructs an address from a buffer base and several offsets using a chain of additions, even though the equivalent pointer is already available in a register. GCC advances its existing pointer instead of rebuilding the address.
[Reproducer on Compiler Explorer](https://godbolt.org/z/5PWY59Gxz): includes C++ source and **original and patched Clang-generated assembly**. The patched assembly follows GCC’s pointer reuse, replacing two address-reconstruction chains with single additions.
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 |
|---:|---:|---:|
| 7.9047 ns/number | 7.2680 ns/number | 5.5928 ns/number |
Originally observed in [simdjson’s fractional-number parsing](https://github.com/simdjson/simdjson/blob/3b2870d822b1797cfebb368cd76df0413a7016bb/include/simdjson/generic/numberparsing.h#L1355-L1363), revision `3b2870d822b1797cfebb368cd76df0413a7016bb`.
This assembly change reduced elapsed time by **0.68–2.20%** in affected simdjson benchmarks.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs