Slashdot Mirror


A Review of GCC 4.0

ChaoticCoyote writes " I've just posted a short review of GCC 4.0, which compares it against GCC 3.4.3 on Opteron and Pentium 4 systems, using LAME, POV-Ray, the Linux kernel, and SciMark2 as benchmarks. My conclusion: Is GCC 4.0 better than its predecessors? In terms of raw numbers, the answer is a definite "no". I've tried GCC 4.0 on other programs, with similar results to the tests above, and I won't be recompiling my Gentoo systems with GCC 4.0 in the near future. The GCC 3.4 series still has life in it, and the GCC folk have committed to maintaining it. A 3.4.4 update is pending as I write this. That said, no one should expect a "point-oh-point-oh" release to deliver the full potential of a product, particularly when it comes to a software system with the complexity of GCC. Version 4.0.0 is laying a foundation for the future, and should be seen as a technological step forward with new internal architectures and the addition of Fortran 95. If you compile a great deal of C++, you'll want to investigate GCC 4.0. Keep an eye on 4.0. Like a baby, we won't really appreciate its value until it's matured a bit. "

23 of 429 comments (clear)

  1. I'll tell you what the problem is... by Anonymous Coward · · Score: 5, Funny

    Well clearly the problem is that you compiled GCC 4.0.0 with GCC 3.4.3! What I did was go through the GCC 4.0 source code in two seperate windows, fire up hexedit in another, and go through line by line "compiling" GCC 4.0 with the GCC 4.0 source, in my head. I wouldn't recommend doing this with -funroll-loops, my hands started cramping up.

    Or you could wait to compile 4.0 until the 3.0 branch makes it to 3.9.9, then it will be close enough anyway. YMMV, people say I give out bad advice, go figure...

    1. Re:I'll tell you what the problem is... by Anonymous Coward · · Score: 5, Informative

      This was meant as a joke, but for those who took this too seriously: if you have ever tried building GCC yourself, you should know that it always recompiles itself.

      A gcc "stage 1" build is gcc compiled with your old compiler. The "stage 2" build is gcc compiled with the compiler created in the previous stage. This is the one that gets installed. The "stage 3" build is optional and verifies that the "stage 2" compiler creates the same output as the previous one.

  2. The performance of compiled code by pclminion · · Score: 5, Informative
    This has always bugged me.

    Some people spend 10 hours tweaking compiler settings and optimizations to get an extra 5% performance from their code.

    Other people spend 2 hours selecting the proper algorithm in the first place and get an extra 500% performance from their code.

    To semi-quote The Matrix: One of these endeavors... is intelligent. And one of them is not.

    1. Re:The performance of compiled code by Minwee · · Score: 5, Insightful

      Unfortunately, including a faster computer with every copy of the code you distribute may be prohibitively expensive.

    2. Re:The performance of compiled code by kfg · · Score: 5, Insightful

      And in both groups you will find people who believe that execution speed is the measurement of code quality.

      KFG

    3. Re:The performance of compiled code by BlurredWeasel · · Score: 5, Insightful

      I run gentoo (not for performance, but mainly because I am familiar with it, and it is easy), and you know what...I don't bug hunt. And adding -fomitframepointer or whatever the hell the option is (its in my flags somewhere) doesn't cost me anything, makes my system say (made up stat) 5% faster and I am happy. It makes no sense why you should deride me (read: gentooers) as an idiot. We're just end users, and if we can get a little bit of performance for free, well why not.

  3. Compilation Speed Test by a KDE developer by Anonymous Coward · · Score: 5, Interesting

    http://www.kdedevelopers.org/node/view/1004

    Qt:
    -O0 -O2
    gcc 3.3.5 23m40 31m38
    gcc 3.4.3 22m47 28m45
    gcc 4.0.0 13m16 19m23

    KDElibs (with --enable-final)
    -O0 -O2
    gcc 3.3.5 14m44 27m28
    gcc 3.4.3 14m49 27m03
    gcc 4.0.0 9m54 23m30

    KDElibs (without --enable-final)
    -O0
    gcc 3.3.5 32m56
    gcc 3.4.3 32m49
    gcc 4.0.0 15m15

    I think KDE and Gentoo people will like GCC 4.0 ;)

  4. Re:I got your value by Martin+Blank · · Score: 5, Funny

    Generally yes, although you'll only have to wait until 16 in some states.

    --
    You can never go home again... but I guess you can shop there.
  5. Re:What about... by scotlewis · · Score: 5, Informative

    Yes and no. The default compiler is GCC4, however, the kernel and much of the OS (pretty much all of Darwin, in fact) are still compiled with GCC3 because they haven't completely cleared the codebase of GCC3-isms.

    That said, remember that the submitter is talking about GCC4 on x86 platforms, and remember that Apple is putting a lot of work into making sure the PowerPC optimizations are as good as possible. Not to mention things like GCC4's auto-vectorization of code to take advantage of the Altivec unit (which has a more noticeable effect than MMXing x86 code).

    It would be nice to see some test results for Apple's GCC versions 3 and 4.

  6. Re:kettle? black? by Dan+Berlin · · Score: 5, Informative

    Significant difference. If you ask gcc folk (like me), we'd happily tell you that 4.0 will probably be, performance wise, win in some cases, and a lose in others. Anytime you add large numbers of optimizations, it takes a while to tune everything else so that we get good generated code. 4.0 is more a test of the new optimizers than something that is supposed to produce spectacular results in all cases.

  7. Re:The Future? by discordja · · Score: 5, Funny

    I can see how that'd throw you off since it's May 2. :)

    --
    I stole this .sig
  8. The value of a baby by Laxitive · · Score: 5, Funny

    "Like a baby, we won't really appreciate its value until it's matured a bit."

    Seriously, this is why I don't appreciate babies. At least after about 4 or 5 years, they're useful for mild manual labour. Sure they'll complain and cry, but all you gotta do is tie their dishwashing to the number of fish heads they're allotted that week. Works pretty well, I gotta say. Anyway, at least they're not a net productivity drain like babies are.

    Anyway, what I mean to say is: from your description, it looks like I'll be staying away from GCC 4 for a while, too. Goddamn babies.

    -Laxitive

  9. Re:intel compiler by MORB · · Score: 5, Interesting

    Intel compiler's reason why it generate faster code is because it does auto-vectorisation (ie, it automatically finds out how to transform some code patterns to take advantage of native vector operation, such as those provided by sse). They started to implement this in gcc 4.0, but it's a veyr first iteration that for what I know is still kinda limited. I'm not even sure it's enabled by default, even in -O3. There are lots of improvement there targeted at gcc4.1.

  10. The ? operator by shreevatsa · · Score: 5, Funny
    The worst part is that they now say that the
    <?
    ,
    >?
    ,
    <?=
    and
    >?=
    operators are deprecated, and will be removed. Damn, I liked them so much. Sure, they weren't part of the standard, and only a GCC extension, but it's just so much more fun to say
    a = b <? c
    than to say
    a = min(b,c)
    or even
    a=b<c?b:c
    . The best use was saying
    a<?=b
    instead of the painful
    a=min(a,b)
    .
    1. Re:The ? operator by Heywood+Jablonski · · Score: 5, Funny
      The worst part is that they now say that the <? , >? , <?= and >?= operators are deprecated...

      That's because they were conflicting with the new gphp front-end.

  11. -ftree-* by Anonymous Coward · · Score: 5, Interesting

    The whole point of gcc4.0.0 is the tree-ssa thing. The author of this test didn't seem to notice that this stuff doesn't get enabled in -O2 nor -O3, but does have to be enabled by hand. This includes autovectorization (-ftree-vectorice) among other things which may make a difference.

    If I was him, I'd repeat the tests again enabling the -ftree stuff when building with gcc4.0.0.

  12. Re:Expected by Rei · · Score: 5, Insightful

    I think the problem is that, if I'm not mistaken, he's testing all C code except Povray. The biggest reported improvements in 4.0 were for g++, so using such a small C++ sample base (Povray - one purpose, one set of design principles, few authors) seems bound to produce inaccurate benchmarking.

    Further, on his most reasonable C benchmark (the Linux kernel), he only records compile time and binary size, but no performance. I call it the most reasonable benchmark because it has thousands of contributors and covers a wide range of code purposes and individual coding habits - and yet, performance is omitted.

    In short, I wouldn't trust this benchmark. Probably the best benchmark would be to build a whole Gentoo system with both, with identical configurations, and check build times and performances ;)

    --
    Dear Lord: One of your creatures may be hurt tonight. Please let it be the other creature.
  13. This is expected, I think by diegocgteleline.es · · Score: 5, Informative

    I found this in the osnews announcement

    "Before we get a bunch of complaints about the fact that most binaries generated by GCC 4.0 are only marginally faster (and some a bit slower) than those compiled with 3.4, let me point out a few things that I've gathered from casually browsing the GCC development lists. I'm neither a GCC contributor nor a compiler expert.

    Prior to GCC 4.0, the implementation of optimizations was mostly language-specific; there was little or no integration of optimization techniques across all languages. The main goal of the 4.0 release is to roll out a new, unified optimization framework (Tree-SSA), and to begin converting the old, fragmented optimization strategies to the unified framework.

    Major improvements to the quality of the generated code aren't expected to arrive until later versions, when GCC contributors will have had a chance to really begin to leverage the new optimization infrastructure instead of just migrating to it.

    So, although GCC 4.0 brings fairly dramatic benefits to compilation speed, the speed of generated binaries isn't expected to be markedly better than 3.4; that latter speedup isn't expected until later installments in the 4.x series."

  14. Re:Expected by markov_chain · · Score: 5, Funny

    Is it that surprising that a Gentoo user thinks of compiling time as the performance metric? :)

    --
    Tsunami -- You can't bring a good wave down!
  15. Re:Expected by Rimbo · · Score: 5, Interesting

    I think the author of the article misunderstands just what happened with GCC 4.0.

    The main improvement in GCC 4.0 is implementing Single Static Assignment.

    SSA is not an optimization. It is a simplification. If you can assume SSA, then it opens the door to an entire class of optimizations that can help improve your performance without affecting your code's correctness.

    That last bit -- optimizing code without affecting correctness -- was a big problem in the days before SSA.

    In that regard, SSA is a similar technology to RISC -- it does not speed things up by itself, but it enables speedups for later on.

    The lack of SSA is one thing that kept gcc out of the hands of compiler researchers. Now that it does that, academia can start hacking away with gcc, and the delay you expect is the time between implementing SSA and implementing all of the optimizations that really will improve code performance.

  16. Users?? by bobbuck · · Score: 5, Funny

    Does Gentoo have users? I though they only had installers.

  17. Re:Expected by ma_luen · · Score: 5, Informative

    I think you are over estimating the interest of the research community in working on gcc. The move from the intentionally underdocumented and ill defined intermediate representations to tree ssa is a huge step for gcc. Unfortunately, there is still no real effort to make the platform attractive to do experimental work on.

    The McCat compiler from McGill (which is what gcc borrowed the ssa rep from), C-- or the LLVM project all provide a much nicer platform. The internal representation is clearly documented, there are frameworks and examples for writing new passes and most importantly they all allow for whole program compilation.

    Until gcc decides to support some of this the project will continue to be ignored by research groups. This might be fine since research compiler work can be fairly ugly and it is just easier to port what works.

    Otherwise I agree that the move to ssa form is a critical step for gcc to take and it will enable it to become a "modern" compiler. More emportantly it will enable the inclusion of the large body of compiler work that is based on ssa forms.

    Mark

  18. Re:No, the third run is for finding bugs by Anonymous Coward · · Score: 5, Informative

    Yes, as long as it wasn't miscompiled.

    Historically, GCC tends to bring out the worst in compilers. That is why when you build GCC, the system compiler will be used once, /without optimizations/ to produce a slow GCC 4.0 which can be used to compile itself. This is done twice (stage 1 compiles stage 2 and stage 2 compiles stage 3) so that 2 and 3 can be compared to ensure that there were no miscompilations, as it is unlikely that a miscompiled compiler will produce correctly executable machine code that replicates exactly.

    Unlikely but possible. Look for the paper "Reflections on trusting trust" for a beautiful hack involving intentional miscompilations. The author basically changed the compiler so that when "login" was being compiled, the compiler inserted a back door. And when a new compiler was being compiled, the compiler would insert the code to insert the back door and to change the next compiler. And then no matter how much you checked teh source to either login or the compiler, you would never notice the back door.