Taz bisounours-codeur | Code :
- #include <vector>
- typedef std::vector<float> Vector;
- double sum(const Vector &v)
- {
- double s = 0.0;
- for (unsigned i = 0; i != v.size(); ++i)
- s += v[i];
- return s;
- }
- /*
- .L5:
- slwi 0,9,2
- addi 9,9,1
- lfsx 0,3,0
- fadd 1,1,0
- bdnz .L5
- */
- double sum(const float v[], unsigned len)
- {
- double s = 0.0;
- for (unsigned i = 0; i != len; ++i)
- s += v[i];
- return s;
- }
- /*
- .L12:
- lfsx 0,9,3
- fadd 1,1,0
- .L11:
- slwi 9,10,2
- addi 10,10,1
- bdnz .L12
- */
|
gcc 4.0 -O2, c'est exactement pareil |