AVR: Constants and loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is AVR-GCC 4.8.1.

The problem: I have a state machien which looks like this:

    void foo() {
        some_setup;
        while(1) {
            switch(whatever) {
                case (whatever): global_var = some_constant;
                [ repeat 10 times ]
                case (special): return;
            }
        }
    }

The problem with this loop is that AVR has many registers. GCC thinks that
it will run sufficiently often that pre-seeding registers with all of these
"some_constant"s before entering the loop is a net win. Unfortunately that
is not true in my case; worse, the set-up takes *much* too long. Also, I'm
using -Os and this "optimization" definitely makes the code larger.

Is there a way to turn this type of optimization off? Moving the loop's guts
to a different function won't work because its innards depend on a couple of
variables created by "some_setup" which I don't want to pass as arguments
(besides, that'd be too slow). "while(__builtin_expect(1,0))" doesn't fix
the problem either.

-- 
-- Matthias Urlichs





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux