   gcc vs. VC++ code optimization
  I'm thinking to move my raytracer from a VS solution to an Eclipse project, but as compiler optimizations skills are fundamental in such kind of applications, I would like to know how do they compare in the most recent version (for gcc the windows port). I was not able to find reliable and recent benchmarks, someone has any knowledge to share?Please, no flames!Note: I know that some IDEs (perhaps Eclipse too) can make use of the VC++ compiler, but I really like VS so I will move only if by doing so I can leave the proprietary software (main reason to do that).Thank you!   
  There's just no way to compare in a way that is both general and accurate. The general understanding is that VC++ produces somewhat more optimized code, but I've had code that VC++ did a really idiotic job on compared to GCC. Luckily, moving code between VC++ and MingW is painless... there's usually some latent header problems that show up, maybe you need to redo some dynamic linking stuff, but nothing requiring large-scale refactoring. (Expect to spend a lot more time if you insist upon a quiet -Wall.)   ;  My experience is that gcc is0) more up-to-date (way shorter release cycles)1) optimizes better 2) comes with a more optimized stdlibc++ (e.g. MSVC's implementation of valarray does, in contrary to gcc's provision, not use expression templates)As for 1), some months ago I coded some expression templates to be used for spectral computations in picogen. I tried out some benchmark in both gcc and msvc. The MSVC version was only roughly only at 50% of gcc's performance, with standard optimization flags (read: -O3 and the MSVC alternative).If you must rely on assembly for some reason, than gcc will integrate it with the rest of your code and apply optimizations, as compared to MSVC, where inline assembly does not work on x64 and where it puts some serious contraints on surrounding code and surrounding function.gcc is also pretty good at auto-vectorization and SSE code generation. I'll try to do some re-creatable benchmarking later, and come back to thread :)edit:On the other hand, here are some not serious to bones benchmarks:http://keyj.s2000.ws/?p=86 -> basically MSVC==gcc, but it's from soon 2009, and there have been major improvements like the merge of the graphite branch into gcc 4.4 and addition of whopr / link-time optimizations in gcc 4.5. So if it is the case that MSVC dit not improve very, very much since the last version, the winner is divinable (from real world: picogen with gcc 4.4 is roughly 1.4 times faster than with gcc 4.3).Btw, gcc's support for C++0x is more mature: gcc / msvc.And, it is often a mistake by ppl to assume that gcc is developed by "freetards" (not that it would mean anything, but), but this and that (only one of many examples) tell another story.[Edited by - phresnel on June 2, 2010 4:37:07 AM];  Thank you both.@phresnel: your experience is expecially valuable for me as you are working on somewhat similar algorithms. If, as I suppose, you are talking about gcc under windows, then I should seriouly consider moving my code to gcc.Thank you!   ;  When I was working on a PS3/Xbox game, the Xbox's VC based compiler generated significantly better code than the PS3's GCC port. There were a number of major optimizations (entire categories) missing from GCC, including whole-program. It also tended to generate longer code that ruined its own inlining logic. I don't know to what extent that applies to the PC platform -- but IMO using GCC on Windows is a bad idea anyway. You should be using the preferred tools and compiler chain for any given platform unless there's a really compelling reason not to. At least that's how I see things.   ;  From my understanding, GCC used to have issues with compiling templated classes -- I don't know if that's true or if it's been fixed since if it were ever a problem, but thought I'd throw in my halfpence.If you're working with Windows, though, use VC++. It's the preferred compiler for the platform, and should generate the best code for it 99% of the time.   ;Quote:Original post by PromitWhen I was working on a PS3/Xbox game, the Xbox's VC based compiler generated significantly better code than the PS3's GCC port. There were a number of major optimizations (entire categories) missing from GCC, including whole-program. It also tended to generate longer code that ruined its own inlining logic. I don't know to what extent that applies to the PC platform -- but IMO using GCC on Windows is a bad idea anyway. You should be using the preferred tools and compiler chain for any given platform unless there's a really compelling reason not to. At least that's how I see things.Recently, GCC has undergone some massive improvements...  gcc on ps3 was what, 3.2? 3.4? 4.1? All those issues have been fixed in 4.4 or 4.5.  From my personal experience, this is not exactly a fair metric, because of OS and processor differences, but recently I compiled a number-crunching program of mine on Win7 with msvc and an i7 processor, and the same program on ubuntu 10.04 with gcc 4.4 and a core 2 duo at half the clock.  Amazingly, despite a significant decrease in processor speed and memory, gcc 4.4 CREAMED msvc, with a factor of 3 speedup on the same code. YMMV ;Quote:Original post by PromitWhen I was working on a PS3/Xbox game, the Xbox's VC based compiler generated significantly better code than the PS3's GCC port. There were a number of major optimizations (entire categories) missing from GCC, including whole-program. It also tended to generate longer code that ruined its own inlining logic. I don't know to what extent that applies to the PC platform -- but IMO using GCC on Windows is a bad idea anyway. You should be using the preferred tools and compiler chain for any given platform unless there's a really compelling reason not to. At least that's how I see things.GCC for PPC not that great from my experience, compared to say, IBM's. Even more so on CELL. That's understandable however; I expect x86 GCC gets much more attention than most other platforms.   ;Quote:Original post by Steve132Recently, GCC has undergone some massive improvements...  gcc on ps3 was what, 3.2? 3.4? 4.1? All those issues have been fixed in 4.4 or 4.5.3.4, IIRC, and the SN compiler was becoming the favored tool rather than GCC. I don't deny I might be out of date.Quote:  From my personal experience, this is not exactly a fair metric, because of OS and processor differences, but recently I compiled a number-crunching program of mine on Win7 with msvc and an i7 processor, and the same program on ubuntu 10.04 with gcc 4.4 and a core 2 duo at half the clock.  Amazingly, despite a significant decrease in processor speed and memory, gcc 4.4 CREAMED msvc, with a factor of 3 speedup on the same code. YMMVI'd be cautious about blaming this difference on compilers, given that you're looking at completely different everything.   ;Quote:Original post by PromitQuote:Original post by Steve132Recently, GCC has undergone some massive improvements...  gcc on ps3 was what, 3.2? 3.4? 4.1? All those issues have been fixed in 4.4 or 4.5.3.4, IIRC, and the SN compiler was becoming the favored tool rather than GCC. I don't deny I might be out of date.Quote:  From my personal experience, this is not exactly a fair metric, because of OS and processor differences, but recently I compiled a number-crunching program of mine on Win7 with msvc and an i7 processor, and the same program on ubuntu 10.04 with gcc 4.4 and a core 2 duo at half the clock.  Amazingly, despite a significant decrease in processor speed and memory, gcc 4.4 CREAMED msvc, with a factor of 3 speedup on the same code. YMMVI'd be cautious about blaming this difference on compilers, given that you're looking at completely different everything.Yeah, you are totally right, like I said, its not a fair metric, and I'd love to do real and fair benchmarks.  The only reason it struck me was the fact that between the two machines, the gcc one had everything conventional wisdom says is an extreme disadvantage.  The processor was 3 years older, the system had a quarter of the memory, and the FSB was half as fast, and it STILL outperformed it.