Thread: GCC 4.2.0 SRA optimization

  1. #1
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396

    GCC 4.2.0 SRA optimization

    I'd like to point out that as of version 4.2.0, GCC now supports SRA -- scalar replacement of aggregates. I've been doing some preliminary testing, and seen improvements of up to 30% speed increase for template algorithms that heavily instantiate various simple objects.

    Generic programming just got a lot more efficient.

    Yet another reason for me to harp my favorite points:

    1) Strive to create constructors that have no side effects
    2) Hold all data by value whenever possible

  2. #2
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Too bad my GCC hates me.

    Code:
    [austin@continuum ~]$ gcc --version | head -1
    gcc (GCC) 4.2.1
    [austin@continuum ~]$ cat > test.c
    int main() { return 42; }
    [austin@continuum ~]$ gcc test.c
    /usr/lib/gcc/i686-pc-linux-gnu/4.2.1/ld: unrecognized option '--hash-style=both'
    /usr/lib/gcc/i686-pc-linux-gnu/4.2.1/ld: use the --help option for usage information
    collect2: ld returned 1 exit status
    [austin@continuum ~]$
    (damn you bleeding edge! damn you!)
    gcc3 to the rescue, though.

    Seriously though, quite an impressive increase in efficiency I'd say. Mind posting a couple of benchmarks?
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Mad_guy, perhaps you need to update your binutils?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by CornedBee View Post
    Mad_guy, perhaps you need to update your binutils?
    This is what I'm figuring, however, the entire system is up to date.
    I've BEEN up to date for a while, I'm fairly religious about not letting updates pile ontop of me.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Would that make much difference to this thread - http://cboard.cprogramming.com/showthread.php?t=88491 if anyone besides myself can remember.

  6. #6
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Mad_guy View Post
    Too bad my GCC hates me.
    Looks like your GCC build and binutils are out of sync. This can happen even if you have up-to-date binutils, if you installed a GCC binary that was compiled against some other version of binutils. Did you compile 4.2.1 yourself, or install from binary?

    You can work around it for now by using an older GCC for the linking step. You can still compile with 4.2.1.

    Best thing, though, is probably to compile your own 4.2.1 build. The GCC build process has become much easier to handle lately. It can take a while, though.

  7. #7
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by twomers View Post
    Would that make much difference to this thread - http://cboard.cprogramming.com/showthread.php?t=88491 if anyone besides myself can remember.
    I'm still getting my grips on the behavior of GCC 4.2.x so I couldn't really say for certain. Best thing is to try it and see!

  8. #8
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Believe me I would but it's slightly awkward at the moment.

  9. #9
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by brewbuck View Post
    Looks like your GCC build and binutils are out of sync. This can happen even if you have up-to-date binutils, if you installed a GCC binary that was compiled against some other version of binutils. Did you compile 4.2.1 yourself, or install from binary?

    You can work around it for now by using an older GCC for the linking step. You can still compile with 4.2.1.

    Best thing, though, is probably to compile your own 4.2.1 build. The GCC build process has become much easier to handle lately. It can take a while, though.
    I installed from binary however, the problem was solved as GCC was calling out to a version of ld that was out of date (how ld got in that particular location, I have no idea.) It simply involved deleting that version of ld in that directory.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick Compilation Question
    By chacham15 in forum C Programming
    Replies: 10
    Last Post: 10-12-2008, 08:15 PM
  2. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  3. Replies: 4
    Last Post: 09-02-2007, 08:47 PM
  4. Compiles on gcc 3.3 but not on gcc 4.0.3
    By cunnus88 in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2007, 12:24 PM
  5. gcc
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-22-2003, 03:46 PM