public inbox for gentoo-amd64@lists.gentoo.org
 help / color / mirror / Atom feed
From: Ian McCulloch <ianmcc@physics.uq.edu.au>
To: "gentoo-amd64@lists.gentoo.org" <gentoo-amd64@lists.gentoo.org>
Subject: Re: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems
Date: Fri, 1 Jul 2011 12:15:10 +1000 (EST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1107011157410.2559@beta.physics.uq.edu.au> (raw)
In-Reply-To: <20110630212321.ad403843.frank.peters@comcast.net>


On Fri, 1 Jul 2011, Frank Peters wrote:

> On Fri, 1 Jul 2011 00:58:46 +0000 (UTC)
> Duncan <1i5t5.duncan@cox.net> wrote:
>
>>
>> I had wondered if this might be an "undefined behavior" optimization bug,
>>
>
> Well, the amd64 users list may not be the appropriate place to discuss
> C programming, but the problem here stems from attempting to do things
> with C that are not supposed to be done with C.  Such things are aptly
> called "tricks" because they stray away from the convention.

I don't think that is true - C has ALWAYS had rules on strict aliasing, 
even from the first attempts at standardization.

Unfortunately it is only recently that common compilers and hardware have 
really taken advantage of the way the language works to give better 
optimizing performance by storing more variables in registers rather than 
reloading pointers from memory every time.  Mostly this is due to the 
small number of registers in the x86 architecture, doesn't lend itself to 
these optimisations as well as other architectures.  Contrast with Itanium 
for example with lots of registers, some of which are designed to be 
preserved across a function call.  FORTRAN compilers have taken advantage 
of aliasing optimizations right from the beginning (ie, since the 
1960's!), and commodity C compilers are only now just catching up!  So 
these are hardly new optimizations.

>
> Ideally, I suppose, for these purposes would be to use assembly language
> routines mixed into the C code.  But this is not as easy as with the
> "tricks."

Not at all, it is about producing more efficient assembly, using the 
language rules that have existed practically forever.  If programmers have 
become accustomed to violating those rules, then they'll just have to get 
accustomed to not violating them.  The rules aren't hard!  And if you DO 
want to alias pointers of different types, then there are well-defined 
ways of doing that, and the resulting code tends to be much more readable 
too.

Regards,
Ian




  parent reply	other threads:[~2011-07-01  3:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 21:45 [gentoo-amd64] GCC-4.5.2 Has Serious Problems Frank Peters
2011-06-30 22:30 ` Alex Schuster
2011-06-30 23:34   ` Frank Peters
2011-06-30 23:35 ` [gentoo-amd64] " Nikos Chantziaras
2011-06-30 23:44   ` Nikos Chantziaras
2011-07-01  0:04     ` Frank Peters
2011-07-01  0:11       ` Nikos Chantziaras
2011-07-01  0:58         ` Duncan
2011-07-01  1:23           ` Frank Peters
2011-07-01  1:52             ` Duncan
2011-07-01  2:15             ` Ian McCulloch [this message]
2011-07-01  4:36             ` Mark Knecht
2011-07-01  5:22               ` Frank Peters
2011-07-01  0:25     ` Frank Peters
2011-07-01  1:04     ` Frank Peters
2011-07-01  2:18       ` Duncan
2011-07-01  2:22       ` Barry Schwartz
2011-07-01  2:43         ` Frank Peters
2011-07-01 11:53       ` Nikos Chantziaras
2011-07-01 16:53         ` Frank Peters
  -- strict thread matches above, loose matches on Subject: below --
2011-07-01  2:30 Ian McCulloch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.02.1107011157410.2559@beta.physics.uq.edu.au \
    --to=ianmcc@physics.uq.edu.au \
    --cc=gentoo-amd64@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox