From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QcUJN-0000m6-Ki for garchives@archives.gentoo.org; Fri, 01 Jul 2011 03:22:34 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 06EEE1C004; Fri, 1 Jul 2011 03:21:06 +0000 (UTC) Received: from mailhub3.uq.edu.au (mailhub3.uq.edu.au [130.102.148.131]) by pigeon.gentoo.org (Postfix) with ESMTP id 7DA321C004 for ; Fri, 1 Jul 2011 03:21:04 +0000 (UTC) Received: from smtp4.uq.edu.au (smtp4.uq.edu.au [130.102.128.19]) by mailhub3.uq.edu.au (8.13.8/8.13.8) with ESMTP id p612FAwx000627 for ; Fri, 1 Jul 2011 12:15:10 +1000 Received: from lorentz.physics.uq.edu.au (lorentz.physics.uq.edu.au [130.102.172.3]) by smtp4.uq.edu.au (8.13.8/8.13.8) with ESMTP id p612FA8E005983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 1 Jul 2011 12:15:10 +1000 Received: from beta.physics.uq.edu.au (beta.physics.uq.edu.au [130.102.172.183]) by lorentz.physics.uq.edu.au (8.13.1/8.13.1) with ESMTP id p612FAwR016351 for ; Fri, 1 Jul 2011 12:15:10 +1000 Date: Fri, 1 Jul 2011 12:15:10 +1000 (EST) From: Ian McCulloch To: "gentoo-amd64@lists.gentoo.org" Subject: Re: [gentoo-amd64] Re: GCC-4.5.2 Has Serious Problems In-Reply-To: <20110630212321.ad403843.frank.peters@comcast.net> Message-ID: References: <20110630174530.9bcbcd47.frank.peters@comcast.net> <20110630200424.0d6d49ef.frank.peters@comcast.net> <20110630212321.ad403843.frank.peters@comcast.net> User-Agent: Alpine 2.02 (LFD 1266 2009-07-14) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-amd64@lists.gentoo.org Reply-to: gentoo-amd64@lists.gentoo.org MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-UQ-FilterTime: 1309486510 X-Scanned-By: MIMEDefang 2.58 on UQ Mailhub on 130.102.148.131 X-Archives-Salt: X-Archives-Hash: 9a1d9c0d129016039512e5ee2f32ee14 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