Skip to content

Conversation

@shattered
Copy link
Contributor

This is quite hacky and probably not fit for merge as is, but does save about 1% of binary size:

13900->13736 bin/cowasm-for-pdp11-with-unixv7
35606->35408 bin/cowbe-for-pdp11-with-unixv7
39640->39218 bin/cowfe-for-pdp11-with-unixv7
10128->10008 bin/cowlink-for-v7unix-with-unixv7

Thoughts?

@davidgiven
Copy link
Owner

The problem with this is that if the label is jumped to from elsewhere, the cached registers won't contain the right value. Real compilers deal with this by unifying the registers at every location in the code which could jump to the label but cowbe doesn't do this. I'm actually surprised that the tests pass.

That the tests do pass suggests that cowbe's register usage is horribly suboptimal, which should come as no surprise. I did try a layer which allocates registers in a round-robin approach so to increase the chance of being able to reuse values in the future but I vaguely recall it was almost worthless and I think I removed it again?

One thing to do is to try and shrink cowbe enough that it can process entire basic blocks in one go, which should help this. But that'll be a painful amount of work.

@shattered
Copy link
Contributor Author

I did try a layer which allocates registers in a round-robin approach so to increase the chance of being able to reuse values in the future but I vaguely recall it was almost worthless and I think I removed it again?

FindPreferredRegister? It's still there, and does help somewhat, but does not appear to respect register aliases (see example in #158)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants