in the mspgcc documentation "Appendix E - Tips and tricks"
  http://mspgcc.sourceforge.net/doc_appendixE.html
trick #18 ends with

    Alternatively, you can mark these loops as volatile:

       for(i=0;i<1234;i++) __asm__ __volatile__("; loop");

    This example does not introduce any extra code and will work as you think.

If I use -O2 or -Os the loop gets unrolled somewhat still,
even if I throw in -fno-unroll-loops.
(If I add -fno-strength-reduce then the loop is not unrolled)

It is very surprising to change the limit from 1234 to 1000 and
then the loop is unrolled 25x (so the index is incremented by 25)
        limit   #times unrolled
        1234    2
        1024    32
        1024    27
        1000    25

I would imagine that these similar sized loops would
execute at unexpected speeds!

 (Better heed the previous warning, and use timers,
  or make the index volatile )


Reply via email to