This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Optimising std::find on x86 and PPC
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- To: Chris Jefferson <caj at cs dot york dot ac dot uk>
- Cc: Paolo Carlini <pcarlini at suse dot de>, libstdc++ <libstdc++ at gcc dot gnu dot org>, Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Date: Tue, 14 Dec 2004 20:09:33 +0100
- Subject: Re: Optimising std::find on x86 and PPC
caj@cs.york.ac.uk said:
> Yep, with -funroll-loops -O3 on last week's CVS, if I give:
> int* check(int* a,int* b)
> {
> for(;a<b;++a)
> if(*a==1) return a;
> return a;
>
}
Funny, replace the int* with int (or unsigned) and the unrolling occurs (7 times).
The difference appears in the loop2 dump:
;; Considering unrolling loop with runtime computable number of iterations
;; Decided to unroll the runtime computable times rolling loop, 7 times.
With the pointer version, the same lines are:
;; Considering unrolling loop with runtime computable number of iterations
;; Unable to prove that the number of iterations can be counted in runtime
Looks like the loop optimizer need to learn about pointer arithmetic.
It could be some aliasing problem, though I do not see how... a and b
are different variables, and I can't see how modifying a would change b.
There were issues with arithmetic overflow last month, but I do not
see why unsigned would work and not int* ???
Actually even an empty loop is not unrolled in this case (I think
empty loops were the topic of the last month thread).
At first sight (ie without measurements), this should hurt C++ containers
a lot, since most loop are looking this way and can never be unrolled.
With such a behaviour, I not sure the C++ abstraction benchmark would
ever give good results.
Certainly some loop gouroo will know much better if it is possible to
do something to improve this situation...
Theo.
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------