RE : Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-14 Thread Etienne Lorrain
--- Andrew Haley <[EMAIL PROTECTED]> wrote: > Etienne Lorrain writes: > > > The correct version is I think, > > > > > > void longcpy(long* _dst, long* _src, unsigned _numwords) > > > { > > > asm volatile ( > > > "cld \n\t" > > > "rep \n\t" > > >

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-14 Thread Andrew Haley
[EMAIL PROTECTED] writes: > On Tue, Jun 13, 2006 at 12:01:39PM +0100, Andrew Haley wrote: > > > > All you've got here is an inline asm version of > > > > inline void longcpy(long* _dst, long* _src, unsigned _numwords) > > { > > __builtin_memcpy (_dst, _src, _numwords * sizeof (long));

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-14 Thread Andrew Haley
Etienne Lorrain writes: > > The correct version is I think, > > > > void longcpy(long* _dst, long* _src, unsigned _numwords) > > { > > asm volatile ( > > "cld \n\t" > > "rep \n\t" > > "movsl \n\t" > >// Outputs (read/write) > >

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-14 Thread Etienne Lorrain
> The correct version is I think, > > void longcpy(long* _dst, long* _src, unsigned _numwords) > { > asm volatile ( > "cld \n\t" > "rep \n\t" > "movsl \n\t" > // Outputs (read/write) > : "=S" (_src), "=D" (_dst), "=c" (_numwords) >

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-13 Thread andrew
On Tue, Jun 13, 2006 at 12:01:39PM +0100, Andrew Haley wrote: > > All you've got here is an inline asm version of > > inline void longcpy(long* _dst, long* _src, unsigned _numwords) > { > __builtin_memcpy (_dst, _src, _numwords * sizeof (long)); > } > > which gcc will optimize if it can. >

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-13 Thread Andrew Haley
[EMAIL PROTECTED] writes: > On Tue, Jun 13, 2006 at 10:37:29AM +, [EMAIL PROTECTED] wrote: > > On Mon, Jun 12, 2006 at 04:59:04PM -0700, Ian Lance Taylor wrote: > > > > > > Probably better to say that these are read-write operands, using the > > > '+' constraint. > > > > > > > Now ever

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-13 Thread andrew
On Tue, Jun 13, 2006 at 10:37:29AM +, [EMAIL PROTECTED] wrote: > On Mon, Jun 12, 2006 at 04:59:04PM -0700, Ian Lance Taylor wrote: > > > > Probably better to say that these are read-write operands, using the > > '+' constraint. > > > > > Now everything works fine at -O3. However, I really don

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-13 Thread andrew
On Mon, Jun 12, 2006 at 04:59:04PM -0700, Ian Lance Taylor wrote: > > Probably better to say that these are read-write operands, using the > '+' constraint. > > > Now everything works fine at -O3. However, I really don't understand > > the '&' early clobber constraint modifer. What use is it? >

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Ian Lance Taylor
[EMAIL PROTECTED] writes: > void longcpy(long* _dst, long* _src, unsigned _numwords) > { > asm volatile ( > "cld \n\t" > "rep \n\t" > "movsl \n\t" > // Outputs > : > // Inputs > : "S" (_src), "D" (_dst), "c" (_numwords)

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
Ok, I think I have tracked this down to having broken the aliasing rules, and for the sake of completeness, here was the problem: Recall that the (big picture) code works fine at -O2, but fails at -O3. The problem seemed to stem from this inline assembly function: void longcpy(long* _dst, long* _

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Mike Stump
On Jun 12, 2006, at 5:45 AM, [EMAIL PROTECTED] wrote: Well, my point above was that -strict-aliasing is included in -O2 and my code works fine at -O2. Only -O3 causes problems, so I didn't expect -fno-strict-aliasing to make any difference. Code in violation of the aliasing rules can appear

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
[EMAIL PROTECTED] writes: > > Well, my point above was that -strict-aliasing is included in -O2 and > my code works fine at -O2. Only -O3 causes problems, so I didn't expect > -fno-strict-aliasing to make any difference. That doesn't follow at all. -O3 exposes much more information to the co

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
On Mon, Jun 12, 2006 at 01:40:18PM +0100, Andrew Haley wrote: > [EMAIL PROTECTED] writes: > > On Mon, Jun 12, 2006 at 12:30:50PM +, [EMAIL PROTECTED] wrote: > > > On Mon, Jun 12, 2006 at 02:21:21PM +0200, Richard Guenther wrote: > > > > On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
[EMAIL PROTECTED] writes: > On Mon, Jun 12, 2006 at 12:30:50PM +, [EMAIL PROTECTED] wrote: > > On Mon, Jun 12, 2006 at 02:21:21PM +0200, Richard Guenther wrote: > > > On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > >On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
[EMAIL PROTECTED] writes: > On Mon, Jun 12, 2006 at 02:21:21PM +0200, Richard Guenther wrote: > > On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > > >> > > >> I'm starting to be a little suspicious about host2little()

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
On Mon, Jun 12, 2006 at 12:30:50PM +, [EMAIL PROTECTED] wrote: > On Mon, Jun 12, 2006 at 02:21:21PM +0200, Richard Guenther wrote: > > On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > > >> > > >> I'm starting to be a l

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
On Mon, Jun 12, 2006 at 02:21:21PM +0200, Richard Guenther wrote: > On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > >> > >> I'm starting to be a little suspicious about host2little(). I wonder > >> if that's well-defined.

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
Richard Guenther writes: > On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > > > > > > I'm starting to be a little suspicious about host2little(). I wonder > > > if that's well-defined. > > > > > > I'm just guessing

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
[EMAIL PROTECTED] writes: > On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > > > > I'm starting to be a little suspicious about host2little(). I wonder > > if that's well-defined. > > > > I'm just guessing here becasue I can't see the code. Is it possible > > templat

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Richard Guenther
On 6/12/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > > I'm starting to be a little suspicious about host2little(). I wonder > if that's well-defined. > > I'm just guessing here becasue I can't see the code. Is it possible

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
On Mon, Jun 12, 2006 at 01:01:47PM +0100, Andrew Haley wrote: > > I'm starting to be a little suspicious about host2little(). I wonder > if that's well-defined. > > I'm just guessing here becasue I can't see the code. Is it possible template T swap_endian(T x) { char* a = reint

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
[EMAIL PROTECTED] writes: > On Mon, Jun 12, 2006 at 12:32:36PM +0100, Andrew Haley wrote: > > [EMAIL PROTECTED] writes: > > > I want a reduced test case for this problem for bugzilla, but don't > > > really know the exact cause. I _think_ code is being improperly > > > optimized away, but I

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
On Mon, Jun 12, 2006 at 12:32:36PM +0100, Andrew Haley wrote: > [EMAIL PROTECTED] writes: > > I want a reduced test case for this problem for bugzilla, but don't > > really know the exact cause. I _think_ code is being improperly > > optimized away, but I don't know. This function is part of a >

Re: help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread Andrew Haley
[EMAIL PROTECTED] writes: > I want a reduced test case for this problem for bugzilla, but don't > really know the exact cause. I _think_ code is being improperly > optimized away, but I don't know. This function is part of a > BigInteger library, and works perfectly upto and including -O2, but

help interpreting gcc 4.1.1 optimisation bug

2006-06-12 Thread andrew
I want a reduced test case for this problem for bugzilla, but don't really know the exact cause. I _think_ code is being improperly optimized away, but I don't know. This function is part of a BigInteger library, and works perfectly upto and including -O2, but produces bogus results at -O3, unless