Re: g++ doesn't unroll a loop it should unroll

2006-12-29 Thread Geert Bosch
On Dec 13, 2006, at 17:09, Denis Vlasenko wrote: # g++ -c -O3 toto.cpp -o toto.o # g++ -DUNROLL -O3 toto.cpp -o toto_unroll.o -c # size toto.o toto_unroll.o textdata bss dec hex filename 525 8 1 534 216 toto.o 359 8 1 368 170 to

Re: g++ doesn't unroll a loop it should unroll

2006-12-14 Thread Paolo Bonzini
loop anyway... you C++ people tend to overtax compiler with optimizations. Is it really necessary to do (i == j) * factor when (i == j) ? factor : 0 is easier for compiler to grok? Of course I tried it. It's even slower. Doesn't help the compiler unroll the loop, and now there's a branch at e

Re: g++ doesn't unroll a loop it should unroll

2006-12-14 Thread Benoît Jacob
Le jeudi 14 décembre 2006 08:58, Steven Bosscher a écrit : > On 12/14/06, Benoît Jacob <[EMAIL PROTECTED]> wrote: > > I don't understand why you say that. At the language specification level, > > templates come with no inherent speed overhead. All of the template stuff > > is unfolded at compile ti

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Steven Bosscher
On 12/14/06, Benoît Jacob <[EMAIL PROTECTED]> wrote: I don't understand why you say that. At the language specification level, templates come with no inherent speed overhead. All of the template stuff is unfolded at compile time, none of it remains visible in the binary, so it shouldn't make the

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Benoît Jacob
Le mercredi 13 décembre 2006 23:09, Denis Vlasenko a écrit : > C++ doesn't specify that compiler shall unroll loops, so it cannot be > classified as "real" bug. OK, but then, even if I explicitly ask gcc to unroll loops with -funroll-loops, it still doesn't unroll them completely and is still as

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Denis Vlasenko
Disclaimer: I am not a compiler developer. On Wednesday 13 December 2006 12:44, Benoît Jacob wrote: > I'm developing a Free C++ template library (1) in which it is very important > that certain loops get unrolled, but at the same time I can't unroll them by > hand, because they depend on templat

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Benoit Jacob
On Wed, 13 Dec 2006, Ian Lance Taylor wrote: When I try it, gcc does unroll the loops. It completely unrolls the inner loop, but only partially unrolls the outer loop. The reason it doesn't completely unroll the outer loop is simply that gcc doesn't attempt to completely unroll loops which cont

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Ian Lance Taylor
Benoît Jacob <[EMAIL PROTECTED]> writes: > I'm developing a Free C++ template library (1) in which it is very important > that certain loops get unrolled, but at the same time I can't unroll them by > hand, because they depend on template parameters. > > My problem is that G++ 4.1.1 (Gentoo) do

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Benoît Jacob
I had already tried that. That doesn't change anything. I had also tried passing a higher --param max-unroll-times. No effect. So, any idea? The example program toto.cpp is so simple, I can't believe g++ can't handle it. Surely there must be something simple that I haven't understood? Benoit

Re: g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Steven Bosscher
On 12/13/06, Benoît Jacob <[EMAIL PROTECTED]> wrote: g++ -DUNROLL -O3 toto.cpp -o toto ---> toto runs in 0.3 seconds g++ -O3 toto.cpp -o toto---> toto runs in 1.9 seconds So what can I do? Is that a bug in g++? If yes, any hope to see it fixed soon? You could try adding -funroll-

g++ doesn't unroll a loop it should unroll

2006-12-13 Thread Benoît Jacob
Hi, I'm developing a Free C++ template library (1) in which it is very important that certain loops get unrolled, but at the same time I can't unroll them by hand, because they depend on template parameters. My problem is that G++ 4.1.1 (Gentoo) doesn't unroll these loops. I have written a sta