Issue 237952
Summary [AArch64] Live pointer overwritten and reloaded across a successful loop backedge
Labels new issue
Assignees
Reporter bagrorg
    Clang overwrites an advanced pointer register with a byte load, then reloads the pointer on the next iteration. The successful backedge also passes through checks whose outcomes are already known on that path. GCC uses a separate register for the byte and forwards the pointer directly, bypassing those checks.

[Reproducer on Compiler Explorer](https://godbolt.org/z/4n491G589): includes C++ source and **original and patched Clang-generated assembly**. The patched assembly follows GCC’s pointer reuse and successful-path control flow in this example.

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 |
|---:|---:|---:|
| 4.8337 ns/object | 2.9831 ns/object | 1.3777 ns/object |

Originally observed in [simdjson’s iterator loop](https://github.com/simdjson/simdjson/blob/3b2870d822b1797cfebb368cd76df0413a7016bb/include/simdjson/generic/ondemand/value_iterator-inl.h#L518-L533), revision `3b2870d822b1797cfebb368cd76df0413a7016bb`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to