-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aarch64 unconditionally spills when x86-64 does not #82252
Comments
@llvm/issue-subscribers-backend-aarch64 Author: Jeff Muizelaar (jrmuizel)
Give the following code:
```c++
extern void foo();
struct Vertex {
float x;
float y;
float c;
};
class Foo { int blue; void Foo::write_vertex(float x1, float y1, float c1, float x2, float y2, float c2, float x3, float y3, float c3) {
Foo::write_vertex(float, float, float, float, float, float, float, float, float): // @Foo::write_vertex(float, float, float, float, float, float, float, float, float)
|
In general, the register allocator doesn't model the cost of the prologue/epilogue, or the cost of shrink-wrapping. It just minimizes the number of stores it generates... and the way to do that is to use registers that aren't clobbered by the call, i.e. callee-save registers. (Most targets tailor the register allocation order to prefer caller-save registers, which covers the simplest cases.) The only reason your testcase gets optimized on x86-64 is that the x86-64 calling convention doesn't have any floating-point callee-save registers, so the register allocator is forced to generate spills. If you replace "float" with "int", it does the same thing as AArch64. It's probably not worth modifying the register allocator for this; modifications are hard (both in terms of the actual code, and the difficulty of review/testing/benchmarking/etc.). The only other solution I can see is some form of tail-dup; if you duplicate the stores, the register allocator should do the right thing. |
Give the following code:
The generated x86-64 code only stores to the stack when calling
foo()
however the aarch64 code always spills:The text was updated successfully, but these errors were encountered: