This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fprefetch-loop-arrays on PowerPC


On Sun, 26 May 2002, Jan Hubicka wrote:

> Sometimes gcc suceeds to confuse itself to believe that accesses to same
> array are disjunct.  WOuld be possible to see the source?

I was able to make a small example.
The problem is, in my opinion,  in the following code form
include/g++-v3/bits/stl_algobase.h

232    template<typename _RandomAccessIter, typename _OutputIter>
233      inline _OutputIter
234      __copy(_RandomAccessIter __first, _RandomAccessIter __last,
235             _OutputIter __result,
236             random_access_iterator_tag)
237      {
238        typedef typename iterator_traits<_RandomAccessIter>::difference_type
239            _Distance;
240        for (_Distance __n = __last - __first; __n > 0; --__n) { <<this
241          *__result = *__first;                                  <<loop
242          ++__first;                                             <<
243          ++__result;                                            <<
244        }
245        return __result;
246      }

But perhaps I misunderstood the debugging info.

This is the sample code:

#include <vector>

class test {
public:
  int t1, t2;
  test(int t1_, int t2_) : t1(t1_), t2(t2_) {}
  test( const test &other) : t1(other.t1), t2(other.t2) {}
};

int main(){
  std::vector<test> t1,t2;

  t1.push_back(test(1,2));
  t1.push_back(test(2,3));
  t1.push_back(test(4,5));
  t1.push_back(test(9,0));
  t1.push_back(test(-1,42));

  std::copy(t1.begin(), t1.end(), t2.begin() );

  return 0;
}

Here the noticeable assembler code:

L..151:
        .ei     "/usr/oss/apps/gcc-3.1/include/g++-v3/bits/stl_vector.h"
        .bi     "/usr/oss/apps/gcc-3.1/include/g++-v3/bits/stl_algobase.h"
        .line   237
        .eb     493
        .eb     493
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .bb     237
        .stabx  "__first:r1681",11,131,0
        .stabx  "__result:r1681",10,131,0
        lwz 11,56(1)
        .line   240
        .bb     240
        .bb     240
        .stabx  "__n:r12",66,131,0
        lwz 0,60(1)
        .line   237
        .eb     240
        .eb     240
        lwz 10,104(1)
        .line   240
        .bb     240
        .bb     240
        .stabx  "__n:r12",66,131,0
        subf 0,11,0
        srawi. 9,0,3
        mtctr 9
        ble- 0,L..245
L..253:
        .line   241
        lwz 0,0(11)
        lwz 9,4(11)
        .line   242
        addi 11,11,8
        .line   241
        stw 0,0(10)
        stw 9,4(10)
        .line   243
        addi 10,10,8
        .line   241
        dcbt 0,28     < ===========
        dcbtst 0,28   < ===========
        .line   240
        bdnz L..253
L..245:
        .ei     "/usr/oss/apps/gcc-3.1/include/g++-v3/bits/stl_algobase.h"

I used this build command:
/usr/oss/apps/gcc-3.1/bin/g++ -O2 -fprefetch-loop-arrays -S prefetch.cc
-mcpu=604e -g2

Attached the complete assembly.



mit freundliche Gruessen / kind regards
Andreas Conz

WWW    http://www.neuro.informatik.uni-kassel.de/~andreasc
e-mail andreasc@neuro.informatik.uni-kassel.de


Attachment: prefetch.s.gz
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]