Open Validark opened 2 months ago
@llvm/issue-subscribers-backend-aarch64
Author: Niles Salter (Validark)
The tricky thing here is the potential codesize increase: if there's multiple bits of code that refer to a constant, what do we want to generate?
Otherwise there's not really anything preventing this sort of optimization.
ld4 can be relatively slow compared to the others, but using ldp at least would be nice.
The tricky thing here is the potential codesize increase: if there's multiple bits of code that refer to a constant, what do we want to generate?
Otherwise there's not really anything preventing this sort of optimization.
I suppose you should just collapse what you can, and if you can't collapse something super easily/opportunistically, then don't.
Consider the following code:
Here is the emit:
I am not sure if this is correct aarch64 assembly, but couldn't we have instead done this?
Or even this (if slightly higher latency is acceptable)?
(The particular constants used in this code is just for demonstration purposes. Obviously we could do better in this case, zeroing out numbers higher than 63, with a
cmhi
followed by abic
)LLVM IR:
Godbolt link