Live data from Hacker News

Claude’s C Compiler vs. GCC

harshanu.space

1–10 of 377 posts

Re: Claude’s C Compiler vs. GCC

#2
I think one of the issue is that the register allocation algorithm -- alongside the SSA generation -- is not enough.

Generally after the SSA pass, you convert all of them into register transfer language (RTL) and then do register allocation pass. And for GCC's case it is even more extreme -- You have GIMPLE in the middle that does more aggressive optimization, similar to rustc's MIR. CCC doesn't have all that, and for register allocation you can try to do simple linear scan just as the usual JIT compiler would do though (and from my understanding, something CCC should do at a simple cost), but most of the "hard part" of compiler today is actually optimization -- frontend is mostly a solved problem if you accept some hacks, unlike me who is still looking for an elegant academic solution to the typedef problem.

Re: Claude’s C Compiler vs. GCC

#3

I think one of the issue is that the register allocation algorithm -- alongside the SSA generation -- is not enough. Generally after the SSA pass, you convert all of them into register transfer language (RTL) and then do register allocation pass. And for GCC's case it is even more extreme -- You have GIMPLE in the middle that does more aggressive optimization, similar to rustc's MIR. CCC doesn't have all that, and fo…

What is the typedef problem?

Re: Claude’s C Compiler vs. GCC

#4
It's really cool to see how slow unoptimised C is. You get so used to seeing C easily beat any other language in performance that you assume it's really just intrinsic to the language. The benchmark shows a SQLite3 unoptimised build 12x slower for CCC, 20x for optimised build. That's enormous!

I'm not dissing CCC here, rather I'm impressed with how much speed is squeezed out by GCC out of what is assumed to be already an intrinsically fast language.

Re: Claude’s C Compiler vs. GCC

#5

I think one of the issue is that the register allocation algorithm -- alongside the SSA generation -- is not enough. Generally after the SSA pass, you convert all of them into register transfer language (RTL) and then do register allocation pass. And for GCC's case it is even more extreme -- You have GIMPLE in the middle that does more aggressive optimization, similar to rustc's MIR. CCC doesn't have all that, and fo…

What is the typedef problem?

If stevefan1999's referring to a nasty frontend issue, it might be due to the fact that a name introduced by a typedef and an identical identifier can mingle in the same scope, which makes parsing pretty nasty – e.g. (example from source at end):

  typedef int AA;
  
  void foo()
  {
    AA AA;            /\* OK - define variable AA of type AA */
    int BB = AA * 2;  /\* OK - AA is just a variable name here \*/
  }

  void bar()
  {
    int aa = sizeof(AA), AA, bb = sizeof(AA);
  }

https://eli.thegreenplace.net/2011/05/02/the-context-sensiti...

I don't know off the top of my head whether there's a parser framework that makes this parse "straightforward" to express.

Re: Claude’s C Compiler vs. GCC

#7
The prospect of going the last mile to fix the remaining problems reminds me of the old joke:

"The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time."

Re: Claude’s C Compiler vs. GCC

#8
I think this is a great example of both points of view in the ongoing debate.

Pro-LLM coding agents: look! a working compiler built in a few hours by an agent! this is amazing!

Anti-LLM coding agents: it's not a working compiler, though. And it doesn't matter how few hours it took, because it doesn't work. It's useless.

Pro: Sure, but we can get the agent to fix that.

Anti: Can you, though? We've seen that the more complex the code base, the worse the agents do. Fixing complex issues in a compiler seems like something the agents will struggle with. Also, if they could fix it, why haven't they?

Pro: Sure, maybe now, but the next generation will fix it.

Anti: Maybe. While the last few generations have been getting better and better, we're still not seeing them deal with this kind of complexity better.

Pro: Yeah, but look at it! This is amazing! A whole compiler in just a few hours! How many millions of hours were spent getting GCC to this state? It's not fair to compare them like this!

Anti: Anthropic said they made a working compiler that could compile the Linux kernel. GCC is what we normally compile the Linux kernel with. The comparison was invited. It turned out (for whatever reason) that CCC failed to compile the Linux kernel when GCC could. Once again, the hype of AI doesn't match the reality.

Pro: but it's only been a few years since we started using LLMs, and a year or so since agents. This is only the beginning!

Anti: this is all true, and yes, this is interesting. But there are so many other questions around this tech. Let's not rush into it and mess everything up.

Re: Claude’s C Compiler vs. GCC

#9
You, know, it sure does add some additional perspective to the original Anthropic marketing materia... ahem, I mean article, to learn that the CCC compiled runtime for SQLite could potentially run up to 158,000 times slower than a GCC compiled one...

Nevertheless, the victories continue to be closer to home.

Re: Claude’s C Compiler vs. GCC

#10

I think one of the issue is that the register allocation algorithm -- alongside the SSA generation -- is not enough. Generally after the SSA pass, you convert all of them into register transfer language (RTL) and then do register allocation pass. And for GCC's case it is even more extreme -- You have GIMPLE in the middle that does more aggressive optimization, similar to rustc's MIR. CCC doesn't have all that, and fo…

Note that the LLVM approach to IR is probably a bit more sane than the GCC one. GCC has ~3 completely different IRs at different stages in the pipeline, while LLVM mostly has only canonical IR form for passing data around through the optimization passes (and individual passes will sometimes make their own temporary IR locally to make a specific analysis easier).
Post reply on HN