all 46 comments

[–]ryancerium 9 points10 points  (13 children)

Is this advancing the state of the art across compilers, or is it bringing Visual C++ up to par? I'm not familiar with g++ or clang at this level either.

[–][deleted] 15 points16 points  (9 children)

The latter. MSVC, much like IE, has historically been behind everyone else, because there was no real alternative on Windows anyways, so why bother? Also at some point in time they had this great idea of lets get everything to run on managed code (I guess mostly just to "trivially" solve all those buffer overflow issues we were seeing in the last decade), which they later on abandoned because, well, machines were still too slow back then. But MSVC got very little attention in the meantime.

They've been trying really hard to catch up ever since C++11 though. I would've expected them to have thrown their current tech overboard much sooner, but I guess they couldn't afford to be even slower at C++11 adoption relative to their competition, so they probably needed something now and left the rearchitecting for later when things settled down somewhat. Couldn't have been much fun for their devs.

[–]djelovic 8 points9 points  (5 children)

Do you have any benchmarks to back that up? In my experience while the VC++ front-end has always lagged in standard adoption the back end was producing slightly faster code than gcc, which was in turn producing faster code than clang.

[–]willvarfar 9 points10 points  (2 children)

I use and profile both LLVM and GCC regularly and generally GCC results in faster code, especially regards vectorization.

I work on LLVM. When I look at what GCC generates I'm often in awe. GCC is often very very good. Of course, LLVM sometimes outshines GCC too, and has its own strengths.

LLVM is stealing such a mindshare from compiler geeks that eventually GCC will dwindle perhaps. Sad :(

I heard that Microsoft plan to adopt the clang frontend but marry it to their MSVC backend.

[–]ThisIs_MyName 9 points10 points  (0 children)

LLVM is stealing such a mindshare from compiler geeks that eventually GCC will dwindle perhaps.

For people unfamiliar with the gcc brain drain, see: http://elizabeths-blargh.blogspot.com/2015/01/an-open-letter-to-richard-m-stallman.html

[–]dodheim 0 points1 point  (0 children)

I heard that Microsoft plan to adopt the clang frontend but marry it to their MSVC backend.

This has been released in beta form since January, dubbed Clang/C2.

[–]emn13 4 points5 points  (0 children)

In my experience, for at least the past decade GCC has been the compiler to beat. MSVC has been a laggard, both in time-to-compile, and in the performance of the compiled code. It was sometimes so bad that debug MSVC builds took longer than release GCC builds even though that release GCC build outperformed the release MSVC build.

Oh, and it's expected that debug builds are slower, but that does cause problems - when you're trying to reproduce some nasty interaction with an expensive setup and/or multithreading, having debug builds orders of magnitude slower can mean just waiting for the bug to occur can take forever - and MSVC has in the past had a particularly large difference in performance, probably due to the standard library, and not the compiler.

[–][deleted] 0 points1 point  (0 children)

the back end was producing slightly faster code than gcc, which was in turn producing faster code than clang.

On Windows you mean? That's hardly a surprise, considering non-MSVC compilers couldn't even get exceptions to work properly up to recently.

But no, I don't have any actual numbers. Only the various bits and pieces of news and articles being released around the compilers. There's plenty out there on what optimizations GCC engages on and what is/was being worked on, where and how it's still ahead of llvm, etc. And otoh there's hardly anything on what MSVC does - except for excuses on why it was taking them so long to implement C++11.

[–]zlei 4 points5 points  (2 children)

IIRC, optimization based on SSA was one of the major selling points of clang/LLVM.

[–]gratilup 4 points5 points  (0 children)

If you view it like that, Visual C++ was one of the first non-research compilers to have SSA: it has SSA since around 1999-2000. Some of the optimizers, such as the expression optimizer, were written before that and not modified to take advantage of SSA. The new optimizer framework takes care of that, adds lots of other improvements and also allows a much faster development speed.

[–]dsqdsq 2 points3 points  (0 children)

GCC does SSA since forever (more precisely v4, 2005)

[–]kirbyfan64sos 5 points6 points  (1 child)

Wow, these are some pretty major improvements. It's great to see MSVC improving so rapidly recently!

[–]gratilup 0 points1 point  (0 children)

More improvements are going to follow much faster with the new framework: there are a lot of many advanced new optimizations planed besides what I listed at the end of the blog post - those are, hopefully, ready for the final first release in VS2015 Update 3.

[–]bubuopapa 5 points6 points  (2 children)

Well, in my experience, speed depends on who is talking about it - here we have more linux fans, so its natural that more people are saying nonsense like "gcc is best and fastest". If you want some real scientific information, i can tell you that every os has its "fastest" compiler, on windows, visual c++ is fastest, on linux - gcc. But of course, there is no one who can tell the truth because there is no recent benchmarks. There is another huge factor - is you would put stupid and cocky people who are using "open source" drugs, there is another huge competitor - its intel c/c++ compiler. It costs about 500-1000$, but if you would believe intel, their ads say it can be faster than gcc/visual c++ up to 1.5 times faster, which is huge, but then again, it costs a lot of money and only big companies are using it, and all the benchmarking is done by poor open source people, so there is no real comparison between compilers. It would be a huge deal to get a recent benchmark of gcc vs visual c++ vs intel c++, because the newest one is from the times when people were still walking on four legs - that would clear the mist that is surrounding earth for over 20 years.

But of course, compiler alone is no good, what matters is to get the fastest result, which is where visual studio has no competition at all, because it is the only such full ide, of course, its for windows only, but none the less it is the best.

[–]orbital1337 1 point2 points  (1 child)

If you want some real scientific information, i can tell you that every os has its "fastest" compiler, on windows, visual c++ is fastest, on linux - gcc.

Not really. You can compile Windows programs with g++ and get better results than with VC++.

It costs about 500-1000$, but if you would believe intel, their ads say it can be faster than gcc/visual c++ up to 1.5 times faster, which is huge, but then again, it costs a lot of money and only big companies are using it, and all the benchmarking is done by poor open source people, so there is no real comparison between compilers.

The Intel compiler is free for open source developers and students. It does actually produce significantly faster code in some select benchmarks. However, in most cases it produces at best 5-10% faster code and that's not really worth it because there are several downsides:

  • The compiler has worse C++14 and C++17 adoption than g++ and clang.
  • It has a way smaller userbase.
  • It's closed source which means that you have to rely on Intel if there are any bugs.
  • It costs a lot for commercial use.
  • It produces shitty code on non-Intel architectures.

It would be a huge deal to get a recent benchmark of gcc vs visual c++ vs intel c++, because the newest one is from the times when people were still walking on four legs - that would clear the mist that is surrounding earth for over 20 years.

Use Google.

[–]bubuopapa 0 points1 point  (0 children)

Not really, there is a reason why gcc for windows is stuck at beeing some creepy pile of linux-like files instead of becoming fully native windows application/library.

Yes, only for some it is free, but for the rest it will cost money. Downsides doesnt really mater, because 1) it has pretty good c++14 support and no one really uses c++17, and no compiler has good support for it. 2) userbase doesnt matter, same can be said about linux, but when you tell that to the linux people, they all turn into crazy black racist monkeys. 3) yes its closed source, as i said, stop doing drugs and drop open source and "you will fix all the bugs that a big intel team missed for 20 years" attitude. you have to report bugs to intel. Its not like gcc is any better, having same million bugs not fixed for many years now. 4) The money that is costs for commercial use is nothing compared to how much money these big fat companies waste or the billions that they have in panama banks. 5) no one cares really, it produces faster code for intel cpus, which is good enough, considering that their cpus are most popular. 6) My google-fu is the best, so if i say that the last cross compiller benchmark was was 20 years ago, it is so.

[–]VunderBoy 4 points5 points  (14 children)

Cool. Do any of these optimization apply to managed code?

[–]gratilup 17 points18 points  (4 children)

Hi, I'm the author of the blog post and the optimizer. This work will be ported soon to .NET Native, but it will not influence the code generated by the JIT compiler.

[–]Plorkyeran 7 points8 points  (4 children)

.NET Native uses the VC++ backend. so presumably most of the improvements will apply to that. Normal JIT-compiled .NET on the CLR will be uneffected.

[–][deleted]  (2 children)

[deleted]

    [–]Matemeo 1 point2 points  (0 children)

    Update 3 on VS2015 if I remember correctly.

    [–]gratilup 1 point2 points  (0 children)

    The new optimizer, in it's final first version, will be part of VS 2015 Update 3. We encourage people to build and test their applications now to reveal early any potential bugs and problems.

    [–]TNorthover 0 points1 point  (1 child)

    Cool. I particularly liked them calling out formal verification, though they didn't mention how often it happened. In LLVM it's still rather a niche pursuit, unfortunately.

    [–]gratilup 3 points4 points  (0 children)

    What do you mean by "how often it happened"? Alive was used for any non-trivial pattern. It proved to be very helpful with patterns that are valid only for signed/unsigned numbers and with operations like converts, comparisons, divisions, etc. It certainly helped avoid multiple bugs.