Rockbox mail archive
Subject: Re: Cowon D2 EABI
2010/6/15 Rafaël Carré <rafael.carre_at_gmail.com>
> On Tue, 15 Jun 2010 00:02:14 +0100
> Rob Purchase <rob.purchase_at_googlemail.com> wrote:
> > On 14/06/2010 23:14, Andrew Poelstra wrote:
> > > 2. If you're just counting clock cycles, the 'volatile' specifier
> > > should prevent gcc's loop optimizations, no?
> > 2. Yes, but this generates additional code since extra ldr/str
> > instructions are generated each time the loop counter is accessed,
> You can add 'register' to a variable to (try to) avoid that.
> that would be 'register unsigned long x' in i2c-telechips.c
> If the code is too dependant of the compiler, perhaps just write it in
> Rafaël Carré
The register keyword doesn't help. I committed a solution with a nop but I
know it's not optimal. However, it came to my mind that such a thing could
unsigned long x;
for (x = (unsigned)(FREQ>>22); x; x--)
Clobbering memory is likely to prevent gcc from optimizing the loop away. I
just tested on a x86 with 4.4.1 and it works. And we would get the same
instructions as before.
I'll test it on a real target tonight but anyone is welcome to try and
commit before if it works.
Writing it in assembly could be an option but which one is better between
ugly inline assembly code and ugly C timing code ? :)
Received on 2010-06-15
Page was last modified "Jan 10 2012" The Rockbox Crew