Live data from Hacker News

Optimizations in C++ Compilers

queue.acm.org

1–10 of 21 posts

Re: Optimizations in C++ Compilers

#4

> I went home that evening and created Compiler Explorer. Nice try. You can’t escape being known as a verb now. Everyone knows the tool as godbolt.

Yep, it honestly never occurred to me that the name of the tool wasn't godbolt. I just went to the site and noticed "Compiler Explorer" for the first time, which seems so generic that I never thought of it as a name.

Re: Optimizations in C++ Compilers

#9
> Tail call removal. A recursive function that ends in a call to itself can often be rewritten as a loop, reducing call overhead and reducing the chance of stack overflow.

Most important: this optimization enables pipelined execution.

When people talk about a CPU executing an integer add instruction in ~1 cycle, what they actually mean is that the add has this latency when the CPU pipelines are full.

If you have an 11 stage pipeline... the add can often have a latency of ~11 cycles... if you write the _right_ code for it.

Re: Optimizations in C++ Compilers

#10

> Tail call removal. A recursive function that ends in a call to itself can often be rewritten as a loop, reducing call overhead and reducing the chance of stack overflow. Most important: this optimization enables pipelined execution. When people talk about a CPU executing an integer add instruction in ~1 cycle, what they actually mean is that the add has this latency when the CPU pipelines are full. If you have an 1…

FWIW, at least on intel cpu call instructions are fully pipelined and effectively zero latency (although, like all jump instructions there is a limit of one call every other cycle).
Post reply on HN