gcc -O1 performs better than gcc -O2

2010-02-14 Thread Joakim Tjernlund
Noticed while optimizing crc16 that gcc -O performed much better than gcc -O2 while doing crc16: # > gcc -O1 CRC16.c ;./a.out crc1:f532 crc2:f532 crc16 tv_res:0 :12768 CRC16 tv_res:0 :10795 # > gcc -O2 CRC16.c ;./a.out crc1:f532 crc2:f532 crc16 tv_res:0 :17092 CRC16 tv_res:0 :11581 #> gcc --ve

Re: gcc -O1 performs better than gcc -O2

2010-02-14 Thread Joakim Tjernlund
Richard Guenther wrote on 2010/02/14 19:05:24: > > On Sun, Feb 14, 2010 at 5:51 PM, Joakim Tjernlund > wrote: > > > > Noticed while optimizing crc16 that gcc -O performed much better > > than gcc -O2 while doing crc16: > > Reducing the noise by adding a loop wit

Re: gcc -O1 performs better than gcc -O2

2010-02-14 Thread Joakim Tjernlund
Jakub Jelinek wrote on 2010/02/14 20:21:50: > > On Sun, Feb 14, 2010 at 08:06:20PM +0100, Joakim Tjernlund wrote: > > the warmup isn't really needed after I added memset and inline or not should > > not matter that much are only used once so I think my > > conclusi

PowerPC suboptimal "add with carry" optimization

2010-04-25 Thread Joakim Tjernlund
Noticed that gcc 4.3.4 doesn't optimize "add with carry" properly: static u32 add32carry(u32 sum, u32 x) { u32 z = sum + x; if (sum + x < x) z++; return z; } Becomes: add32carry: add 3,3,4 subfc 0,4,3 subfe 0,0,0 subfc 0,0,3 mr 3,0 Instead of:

Re: PowerPC suboptimal "add with carry" optimization

2010-04-26 Thread Joakim Tjernlund
Ian Lance Taylor wrote on 2010/04/25 20:07:03: > Joakim Tjernlund writes: > > > Noticed that gcc 4.3.4 doesn't optimize "add with carry" properly: > > Please file a missed-optimization report according to > http://gcc.gnu.org/bugs/ . Thanks. I rather not,

Re: PowerPC suboptimal "add with carry" optimization

2010-04-26 Thread Joakim Tjernlund
Ian Lance Taylor wrote on 2010/04/25 20:07:03: > > Joakim Tjernlund writes: > > > Noticed that gcc 4.3.4 doesn't optimize "add with carry" properly: BTW, I can see in gcc src: (define_insn "" [(set (match_operand:CC 0 "cc_reg_operand" &qu

Re: PowerPC suboptimal "add with carry" optimization

2010-04-26 Thread Joakim Tjernlund
Manuel López-Ibáñez wrote on 2010/04/26 13:59:04: > On 26 April 2010 09:13, Joakim Tjernlund > wrote: > > Ian Lance Taylor wrote on 2010/04/25 20:07:03: > >> Joakim Tjernlund writes: > >> > >> > Noticed that gcc 4.3.4 doesn't optimize "add

Re: PowerPC suboptimal "add with carry" optimization

2010-04-26 Thread Joakim Tjernlund
David Edelsohn wrote on 2010/04/26 14:54:55: > > On Mon, Apr 26, 2010 at 8:21 AM, Joakim Tjernlund > wrote: > > Manuel López-Ibáñez wrote on 2010/04/26 13:59:04: > >> On 26 April 2010 09:13, Joakim Tjernlund > >> wrote: > >> > Ian Lance Taylor

Re: PowerPC suboptimal "add with carry" optimization

2010-04-26 Thread Joakim Tjernlund
Manuel López-Ibáñez wrote on 2010/04/26 15:29:54: > > On 26 April 2010 15:22, Joakim Tjernlund > wrote: > > > >> feature enhancement.  Some of the information can be left blank, but > >> if we do not have information about the system and an example, we may >

memcpy(p,p,len)

2010-04-30 Thread Joakim Tjernlund
Is memcpy supposed to work when the src and dest are the same: memcpy(p, p, 100); Jocke

Re: memcpy(p,p,len)

2010-04-30 Thread Joakim Tjernlund
Jan-Benedict Glaw wrote on 2010/04/30 16:10:42: > > On Fri, 2010-04-30 16:08:15 +0200, Joakim Tjernlund > wrote: > > Is memcpy supposed to work when the src and dest are the same: > > memcpy(p, p, 100); > > It may work, but you cannot rely on it. Use memmove() alter

%pc relative addressing of string literals/const data

2010-10-05 Thread Joakim Tjernlund
While doing relocation work on u-boot I often whish for strings/const data to be accessible through %pc relative address rather than and ABS address or through GOT. Has this feature ever been considered by gcc? Jocke

Re: %pc relative addressing of string literals/const data

2010-10-05 Thread Joakim Tjernlund
Ian Lance Taylor wrote on 2010/10/05 15:47:38: > > Joakim Tjernlund writes: > > > While doing relocation work on u-boot I often whish for strings/const data > > to be accessible through %pc relative address rather than and ABS address > > or through GOT. Has this feat

Re: %pc relative addressing of string literals/const data

2010-10-05 Thread Joakim Tjernlund
Richard Henderson wrote on 2010/10/05 20:56:55: > > On 10/05/2010 06:54 AM, Joakim Tjernlund wrote: > > Ian Lance Taylor wrote on 2010/10/05 15:47:38: > >> Joakim Tjernlund writes: > >>> While doing relocation work on u-boot I often whish for strings/const da

Re: %pc relative addressing of string literals/const data

2010-10-05 Thread Joakim Tjernlund
Richard Henderson wrote on 2010/10/05 23:12:19: > > On 10/05/2010 01:55 PM, Joakim Tjernlund wrote: > > I don't do x86 or alpha so let me ask: If you run the code on an address > > != link address, will it do the right thing? > > Yes of course. It wouldn't be

Re: %pc relative addressing of string literals/const data

2010-10-06 Thread Joakim Tjernlund
Alan Modra wrote on 2010/10/06 00:19:26: > > On Tue, Oct 05, 2010 at 11:40:11PM +0200, Joakim Tjernlund wrote: > > yes, but this could be a new PIC mode that uses a new better > > PIC mode for everything. Especially one that doesn't require each function > > to cal

Re: %pc relative addressing of string literals/const data

2010-10-06 Thread Joakim Tjernlund
Gabriel Paubert wrote on 2010/10/06 10:15:26: > > On Tue, Oct 05, 2010 at 10:55:36PM +0200, Joakim Tjernlund wrote: > > Richard Henderson wrote on 2010/10/05 20:56:55: > > > > > > On 10/05/2010 06:54 AM, Joakim Tjernlund wrote: > > > > Ian

Re: %pc relative addressing of string literals/const data

2010-10-07 Thread Joakim Tjernlund
Richard Henderson wrote on 2010/10/06 00:13:22: > > On 10/05/2010 02:40 PM, Joakim Tjernlund wrote: > > Especially one that doesn't require each function > > to calculate the GOT address in the function prologue(why is that so?) > > Because PIC code can be called

Re: %pc relative addressing of string literals/const data

2010-10-07 Thread Joakim Tjernlund
Michael Meissner wrote on 2010/10/07 15:00:25: > > On Tue, Oct 05, 2010 at 11:56:55AM -0700, Richard Henderson wrote: > > On 10/05/2010 06:54 AM, Joakim Tjernlund wrote: > > > Ian Lance Taylor wrote on 2010/10/05 15:47:38: > > >> Joakim Tjernlund writes: > &g

Re: %pc relative addressing of string literals/const data

2010-10-07 Thread Joakim Tjernlund
Michael Meissner wrote on 2010/10/07 20:21:38: > > On Thu, Oct 07, 2010 at 04:50:50PM +0200, Joakim Tjernlund wrote: > > Why not offer some of this on PowerPC32? mcmodel=small would probably be > > enough. > > Well as they say, contributions are welcome. Note, 32-bit mod

Re: %pc relative addressing of string literals/const data

2010-10-09 Thread Joakim Tjernlund
Michael Meissner wrote on 2010/10/07 20:21:38: > > On Thu, Oct 07, 2010 at 04:50:50PM +0200, Joakim Tjernlund wrote: > > Why not offer some of this on PowerPC32? mcmodel=small would probably be > > enough. > > Well as they say, contributions are welcome. Note, 32-bit mo

Re: %pc relative addressing of string literals/const data

2010-10-10 Thread Joakim Tjernlund
Alan Modra wrote on 2010/10/06 00:19:26: > > On Tue, Oct 05, 2010 at 11:40:11PM +0200, Joakim Tjernlund wrote: > > yes, but this could be a new PIC mode that uses a new better > > PIC mode for everything. Especially one that doesn't require each function > > to cal

Re: %pc relative addressing of string literals/const data

2010-10-11 Thread Joakim Tjernlund
Alan Modra wrote on 2010/10/11 14:58:45: > > On Sun, Oct 10, 2010 at 11:20:06AM +0200, Joakim Tjernlund wrote: > > Now I have had a closer look at this and it looks much like -fpic > > on ppc32, you still use the GOT/TOC to load the address where the data is. > > No, wi

Re: %pc relative addressing of string literals/const data

2010-10-12 Thread Joakim Tjernlund
Alan Modra wrote on 2010/10/11 14:58:45: > > On Sun, Oct 10, 2010 at 11:20:06AM +0200, Joakim Tjernlund wrote: > > Now I have had a closer look at this and it looks much like -fpic > > on ppc32, you still use the GOT/TOC to load the address where the data is. > > No, wi

Re: %pc relative addressing of string literals/const data

2010-10-12 Thread Joakim Tjernlund
Joakim Tjernlund/Transmode wrote on 2010/10/09 18:32:40: > > Michael Meissner wrote on 2010/10/07 20:21:38: > > > > On Thu, Oct 07, 2010 at 04:50:50PM +0200, Joakim Tjernlund wrote: > > > Why not offer some of this on PowerPC32? mcmodel=small would probably be en

Re: %pc relative addressing of string literals/const data

2010-10-14 Thread Joakim Tjernlund
Joakim Tjernlund/Transmode wrote on 2010/10/12 11:00:36: > > Alan Modra wrote on 2010/10/11 14:58:45: > > > > On Sun, Oct 10, 2010 at 11:20:06AM +0200, Joakim Tjernlund wrote: > > > Now I have had a closer look at this and it looks much like -fpic > > > on

Re: %pc relative addressing of string literals/const data

2010-10-26 Thread Joakim Tjernlund
Joakim Tjernlund/Transmode wrote on 2010/10/14 15:54:32: > > Joakim Tjernlund/Transmode wrote on 2010/10/12 11:00:36: > > > > Alan Modra wrote on 2010/10/11 14:58:45: > > > > > > On Sun, Oct 10, 2010 at 11:20:06AM +0200, Joakim Tjernlund wrote: > > >

Re: %pc relative addressing of string literals/const data

2010-10-26 Thread Joakim Tjernlund
Alan Modra wrote on 2010/10/27 04:01:50: > > On Wed, Oct 27, 2010 at 12:53:00AM +0100, Dave Korn wrote: > > On 26/10/2010 23:37, Joakim Tjernlund wrote: > > > > > Everything went dead quiet the minute I stated to send patches, what did > > > I do wrong? >

powerpc: What happened to lwzu/stwu in loops?

2010-11-03 Thread Joakim Tjernlund
Using gcc 4.4.4 -Os on loop(long *to, long *from, long len) { for (; len; --len) *++to = *++from; } I get /* gcc 4.4.4 -Os loop: addi 5,5,1 li 9,0 mtctr 5 b .L2 .L3: lwzx 0,4,9 stwx 0,3,9 .L2: addi 9,9,4 bdnz .

Re: powerpc: What happened to lwzu/stwu in loops?

2010-11-03 Thread Joakim Tjernlund
Andrew Pinski wrote on 2010/11/03 17:44:17: > > On Wed, Nov 3, 2010 at 9:02 AM, Joakim Tjernlund > wrote: > > > > Using gcc 4.4.4 -Os on > > You might want to try 4.5.0 which IIRC has a fix for this issue. The > issue is IV-OPTs does not take into account load/sto

Re: %pc relative addressing of string literals/const data

2010-11-08 Thread Joakim Tjernlund
Dave Korn wrote on 2010/10/27 13:59:00: > > On 27/10/2010 07:47, Joakim Tjernlund wrote: > > Alan Modra wrote on 2010/10/27 04:01:50: > >> On Wed, Oct 27, 2010 at 12:53:00AM +0100, Dave Korn wrote: > >>> On 26/10/2010 23:37, Joakim Tjernlund wrote: > >&

const char wd[6] = "Wednes", is that legal?

2010-11-30 Thread Joakim Tjernlund
gcc 4.4.5, powerpc32 does not fail const char wd[6] = "Wednes"; even though wd only has room for 6 chars. Is this intended? Jocke

ppc: const data not in RO section

2010-11-30 Thread Joakim Tjernlund
Why is not const char cstr[] = "mystr"; const int myint = 3; added to a read only section? Especially since const int myarr[]={1,2,3}; is placed in .rodata. hmm, -G 0 does place these in .rodata but why do I have to specify that?

Re: ppc: const data not in RO section

2010-12-01 Thread Joakim Tjernlund
Nathan Froyd wrote on 2010/12/01 18:33:23: > > On Tue, Nov 30, 2010 at 08:04:06PM +0100, Joakim Tjernlund wrote: > > Why is not > > const char cstr[] = "mystr"; > > const int myint = 3; > > added to a read only section? > > Especially since >

Re: ppc: const data not in RO section

2010-12-01 Thread Joakim Tjernlund
Nathan Froyd wrote on 2010/12/01 18:33:23: > > On Tue, Nov 30, 2010 at 08:04:06PM +0100, Joakim Tjernlund wrote: > > Why is not > > const char cstr[] = "mystr"; > > const int myint = 3; > > added to a read only section? > > Especially since >

PowerPC optimization regression

2010-12-08 Thread Joakim Tjernlund
I have noticed gcc 4.4.5 often produces less optimzed code than the old 3.4.6. Below is the latest example. I am starting to wonder if I need rebuild gcc 4.4.5 and/or add new options to gcc when I compile. Any insight? Jocke const char *test(int i) { const char *p = "abc\0def\0gef";

Re: PowerPC optimization regression

2010-12-08 Thread Joakim Tjernlund
David Edelsohn wrote on 2010/12/08 17:38:11: > > On Wed, Dec 8, 2010 at 4:37 AM, Joakim Tjernlund > wrote: > > > > I have noticed gcc 4.4.5 often produces less optimzed code > > than the old 3.4.6. Below is the latest example. I am > > starting to wonder i