Go Down

Topic: Why doesn't Arduino 1.0.1 use the latest GCC? (Read 2 times) previous topic - next topic

stimmer

What I meant was that avr-gcc 4.3.2 and 4.7.0 behave in exactly the same way - so it isn't worth upgrading in the hope that the newer gcc will optimize the shift any better than the old one. I don't know why it doesn't use swap for a right shift, but there may be something I don't know (perhaps it was tried but caused problems) In any case it would only be useful for the fairly rare case of shifting an unsigned byte by 4 places.

It might be a bit too much to expect the compiler to know when it can use a swap - I wouldn't expect it to get x=(x>>4)|(x<<4); down to a single swap! :)

scswift


In any case it would only be useful for the fairly rare case of shifting an unsigned byte by 4 places.

It might be a bit too much to expect the compiler to know when it can use a swap - I wouldn't expect it to get x=(x>>4)|(x<<4); down to a single swap! :)


Actually, I believe the latest version does in fact optimize x=(x>>4)|(x<<4); down to a single swap.  I saw someone use that in an example over on avrfreaks and show the assembly that was generated.

And swap isn't only useful for shifting an unsigned byte 4 places.  It's also useful for shifting unsigned ints and longs.  After all, if you want to shift those right by 4, then every byte in them needs to be shifted right by 4. 

stimmer



Actually, I believe the latest version does in fact optimize x=(x>>4)|(x<<4); down to a single swap.  I saw someone use that in an example over on avrfreaks and show the assembly that was generated.


You're right, it does :) (I don't know why it didn't work earlier, I did try it - but I just tried it again)

MichaelMeissner


What I meant was that avr-gcc 4.3.2 and 4.7.0 behave in exactly the same way - so it isn't worth upgrading in the hope that the newer gcc will optimize the shift any better than the old one. I don't know why it doesn't use swap for a right shift, but there may be something I don't know (perhaps it was tried but caused problems) In any case it would only be useful for the fairly rare case of shifting an unsigned byte by 4 places.

It might be a bit too much to expect the compiler to know when it can use a swap - I wouldn't expect it to get x=(x>>4)|(x<<4); down to a single swap! :)

GCC has been doing the optimization of turning that into a rotate for a long time.  It depends on whether the backend maintainer has described that particular optimization in the <machine>.md file.

westfw

Quote
the version Ardunio is shipping is 4.3.2 which was released on August 27, 2008, so the version is rather old.

It's worth noting that every release of the compiler BETWEEN 4.3 and 4.7 has had bugs that were very significant to Arduino software.   Apparently there aren't very many other gnu-c++ users.

Go Up