[llvm] [BOLT][AArch64] Expand cmpbr when reversing would overflow (PR #202998)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 3 03:50:48 PDT 2026
labrinea wrote:
Hi @rafaelauler, thank you for reviewing and evaluating the runtime cost. Originally I wanted to use liveness analysis both for handling simpler cases like this patch does (check nzcv flags), but also to scavenge registers for adrp stubs.
I am going a bit off on a tangent now to discuss the latter case. After experimentation I found that scavenging sometimes returned a caller-saved register that seemed available, but because it wasn't clobbered by the callee, the caller didn't save/restore it, so the adrp stub used for long distant branches inside the callee ended up clobbering it. To defend agaist this I had to make some changes to liveness analysis, but then I could no longer scavenge a register. An alternative would be to push/pop but this also has complications. I think you are touching these matters in the discussion of [196983](https://github.com/llvm/llvm-project/pull/196983).
I am considering to abandon the idea of scavenging for now, which could make this patch cheaper as you are suggesting, by not building the call graph. Note that we don't currently have hardware that supports FEAT_CMPBR either, therefore this patch is nice to have in the future but not a priority for now. I am happy to refactor according to your suggestions.
https://github.com/llvm/llvm-project/pull/202998
More information about the llvm-commits
mailing list