30 ms·
Whoa, really? Since when?? After a lifetime of using GCC, I (like many others) moved to clang a few years ago, out of frustration with the slow development of
by loxias 4y ago
Whoa, really? Since when??
After a lifetime of using GCC, I (like many others) moved to clang a few years ago, out of frustration with the slow development of GCC, a desire to use new C++ features, and stayed because of the superior error messages and, in my use cases anyway, superior code generation.
In addition, I gather it's a much cleaner and easier to maintain code base. As a result, we get to have cool things like emscripten, llvmpipe, all sorts of static analysis tools that would be more challenging to build in the GCC universe, and much more.
Honestly, I thought GCC was slowing down development wise.
Is GCC worth trying again? Can you name a few "cool new things" I can do with GCC that I can't with clang? There's plenty of the opposite...
- intelVISA 4y agoLLVM always delivers the cooler stuff I'll admit but GCC is ahead as an optimizing compiler, general lang support and generating cryptic messages.
- secondcoming 4y agoInteresting, I've generally found that clang is better at optimising, especially when it comes to auto-vectorisation.
- superdimwit 4y agoAgreed, autovec is in my experience where clang really shines.
- ncmncm 4y agoGcc pretty consistently delivers slightly faster code.
- pyler 4y agoproof?
- ncmncm 4y agoKeyword there is "slightly".
- loxias 4y agoNot in my experience! Though it was a few years ago, I'll have to re-evaluate. In the past, when doing numeric/scientific programming -- lots of dataflow, it was much easier to "coax" clang to generate the right (performant) assembly than GCC. I guess my use is less typical -- the internet agrees with you. :) Hurrah for competition! (of course, neither GCC or clang could _ever_ beat ICC at some of my tests.. grumble)
- DannyBee 4y ago"(of course, neither GCC or clang could _ever_ beat ICC at some of my tests.. grumble)" They never tried, honestly - ICC had plenty of defaults that were targeted at performance above correctness. That's fine - but it wasn't what either clang or gcc was going to go for. Even when trying to compare apples to apples, folks often compared them by trying to get GCC/Clang to emulate the correctness level of ICC (IE give GCC/Clang more freedom), rather than the other way around :) Which, again, similarly understandable, but also a thing that you'd have to spend a while on in GCC/Clang to get to a reasonable place) Small-number-of-target compilers like ICC are also fundamentally easier. Lots of techniques (IE optimal register allocation[1], etc) that add up to performance gains are a lot more tractable to really good applied engineering when they don't have to be so general. Similarly small-target-market compilers are also easier. Over time, high performance was literally ICC's only remaining market. So they can spend their days working on that. GCC/Clang had to care about a lot more. [1] This happens to now be a bad example because advances finally made this particular thing tractable. But it took years more, and feel free to replace it with something like "optimal integrated register allocation and scheduling" or whatever is still intractable to generalize.
- loxias 4y agoYou sound like you know what you're talking about. > They never tried, honestly - ICC had plenty of defaults that were targeted at performance above correctness. Is it possible to get ICC level performance out of open source tools? Much of my CPU bound work relates to array signal processing, which, if you can code it right :) lends itself heavily to SIMD branchless pipelines. Plus some scatter gathers on a group of other cores to calculate a sparse crosscorrelation tensor. I would love to be able to get same or better performing code out of clang or gcc, even it it takes 2-4x more work than with ICC...
- DannyBee 4y agoThis is often true for SPEC, but not true for real world code. Or at least, we extensively tested this at Google, before, during, and after the move to LLVM. On many thousands of libraries, binaries, etc, made up of hundreds of millions of lines of C++. While there were wins and losses, on average, LLVM was a consistent net positive. That was true despite having spent 5+ years of having a large team dedicated to doing nothing but finding places to improve performance of GCC compiled code (and contributing back patches), and doing so very successfully. That said, as time approaches infinity, the compilers are going to generate the best code for the things that someone took the time to analyze and make the compiler better at. There is, in the end, no magic that makes GCC better than LLVM or vice versa. The vast majority of it is tuning and improving things little by little for whatever targets someone is trying to improve.
- ncmncm 4y agoI can only go by the results I measure. There certainly are cases where Clang does better than Gcc, but the difference is anyway rarely more than a couple of percent. Occasionally one finds a factor of two one way or the other, e.g. where one compiler has noticed it can use CMOV without penalty.
- germandiago 4y agoGCC is quite up to date. Also, the code generation used to be better. I do not know right now. But I think it still might have a slight advantage.
- pjmlp 4y agoC++20 support comes to mind, the plethora of supported hardware as well.
- loxias 4y ago> C++20 support? Not that I think it matters but this is, of everything, the strongest argument to me. For shame, clang, for shame! I switched because it had better modern c++ support. Guess the winds are changing.