[LAD] gcc and pointer aliasing... missing optimizations in some cases

From: torbenh <torbenh@email-addr-hidden>
Date: Tue Dec 22 2009 - 18:55:08 EET

hi...

i discovered yesterday, that gcc cant optimize something like:

-----------------------------------------------------------------------
class Ramp
{
    private:
        float _phase;
        float _omega;
    public:
        Ramp();
        float process()
        {
            _phase += _omega;
            return _phase;
        }
};

Ramp osc_block;

int process( jack_nframes_t nframes, void *arg )
{
    int i;

    float * __restrict__ buf = (float *) jack_port_get_buffer( out_port, nframes );

    for( i=0; i<nframes; i++ ) {
        buf[i] = osc_block.process();
    }
}
-----------------------------------------------------------------------

the __restrict__ on buf is not enough to convince gcc that writing to
buf[i] doesnt clobber _phase or _omega;

i am trying to make a case here, that something stronger than
__restrict__ is needed which allows the programmer to state that a
pointer really doesnt alias to anything.

of course the gcc guys say "wont happen" ...
so the question is whether we have enough need for this in the dsp
scene... and maybe some political power ?

am i totally wrong and such idioms arent of much use ?

-- 
torben Hohn
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Tue Dec 22 20:15:05 2009

This archive was generated by hypermail 2.1.8 : Tue Dec 22 2009 - 20:15:06 EET