Back to News
Advertisement
Advertisement

⚑ Community Insights

Discussion Sentiment

50% Positive

Analyzed from 77 words in the discussion.

Trending Topics

#register#registers#allocator#compiler#rcc#stack#still#done#cheaper#fixed

Discussion (1 Comments)Read Original on HackerNews

rurbanβ€’13 minutes ago
It still can be done much cheaper. I just fixed my excessively cheap register allocator for my c compiler rcc.

The register allocator is a simple first-fit bitmask with no spilling to stack except for the two predefined spill slots. Only if all 8 registers are in use, it spills the additional registers on the stack. What they call guest registers. No SSA and no BB needed. No crazy mem2reg or graph-coloring. Only once per function.

Only for very big functions one register is spilled, usually just rsi.

Benchmarks:

    | Compiler | Compile (ms) | Execute (ms) | Total (ms) |
    | :------- | -----------: | -----------: | ---------: |
    | RCC      |           61 |          754 |        815 |
    | TCC      |            8 |          628 |        636 |
    | SLIMCC   |           74 |          642 |        716 |
    | KEFIR    |          270 |          765 |       1035 |
    | GCC0     |           83 |          637 |        720 |
    | GCCO2    |          204 |          227 |        431 |
    | CLANG0   |          377 |          620 |        997 |
    | CLANGO2  |          310 |          221 |        531 |