Skip to content
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

Implement live-range splitting in the register allocator #70

Open
ShivamSarodia opened this issue Apr 8, 2018 · 0 comments
Open

Implement live-range splitting in the register allocator #70

ShivamSarodia opened this issue Apr 8, 2018 · 0 comments

Comments

@ShivamSarodia
Copy link
Owner

I noticed that the following function benefits from live range splitting:

int fib(int i) {
  if(i == 0) {
    return 0;
  } else if(i == 1) {
    return 1;
  } else {
    return fib(i-1) + fib(i-2);
  }
}

As ShivyC compiles this today, the output code is about 25% slower than GCC on my machine for i = 9. ShivyC allocates i on the stack, not in a register, because it must survive a call to the fib function. GCC, on the other hand, places i into the EBX register which is not currently possible in ShivyC because ShivyC does not support callee-saved registers. When adding a range split manually, as follows, ShivyC output performance is roughly comparable to GCC:

int fib(int i) {
  if(i == 0) {
    return 0;
  } else if(i == 1) {
    return 1;
  } else {
    int i2 = i;
    return fib(i2-1) + fib(i2-2);
  }
}

Here, ShivyC keeps i in the edi register, and allocates only i2 on the stack, which improves performance significantly on the comparisons.

The paper Live Range Splitting in a Graph Coloring Register Allocator (link) looks very relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant