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: Paolo Carlini <pcarlini at suse dot de>
- To: Chris Jefferson <caj at cs dot york dot ac dot uk>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 14 Dec 2004 16:33:12 +0100
- Subject: Re: Optimising std::find on x86 and PPC
- References: <41BEF98C.3000403@cs.york.ac.uk>
Chris Jefferson wrote:
I recently tried changing the std::find random_access overload to
change the main loop from:
difference_type __trip_count = (__last - __first) >> 2;
for(; __trip_count > 0 ; --__trip_count) { if(*__first = __val) return
__first; ++__first; (4 times) }
to:
Iterator __newlast = __last - (__last - __first) % 4;
for( ; __first < __newlast;){ if(*__first = __val) return __first;
++__first; (4 times) }
This knocked about 30% off the time taken on x86
You are not giving many details: for instance whether you are seeing the
improvement with/without -funroll-loops, which other optimization
options (loop-unrolling related, in particular) you are using.
Certainly, naively, the first form seems easier to analyze for the loop
unroller.
If we can isolate a specific loop unrolling problem we can certainly ask
Zdenek, Sebastian, Daniel and the others gurus of that area to work on
it, and most probably will be fixed relatively soon.
Paolo.