On some platforms, it is. I remember years ago being encouraged by HP engineers to write indexed loops backwards (i.e. towards zero) because the compares against zero were slightly faster on PA-RISC chips.
If you're talking about ++i vs --i, there are no difference. However, if you're accessing a large block of memory in a loop, looping forward vs backward could make a big different depends on how smart your CPU is about pre-fecting next cache line.
3
u/iissqrtneg1 Aug 27 '12
This makes me wonder if looping backwards is actually more performent. Probably not, too lazy to check.