[LAD] gcc and pointer aliasing... missing optimizations in some cases
Gabriel M. Beddingfield
gabriel at teuton.org
Tue Dec 22 19:21:26 UTC 2009
On Tue, 22 Dec 2009, torbenh wrote:
> class Ramp
> {
> private:
> float _phase;
> float _omega;
> public:
> Ramp();
> float process()
> {
> _phase += _omega;
> return _phase;
> }
> };
Is the problem that _phase and _omega get reloaded from
memory every time they're used?
Would it not work to declare process() as:
float process() __restrict
{ ... }
Thus telling the compiler that `this` is not an alias when
process() is called.
Or perhaps:
> int process( jack_nframes_t nframes, void *arg )
> {
> int i;
>
> float * __restrict__ buf = (float *) jack_port_get_buffer( out_port, nframes );
Ramp * __restrict__ o = &osc_block;
>
> for( i=0; i<nframes; i++ ) {
> buf[i] = osc_block.process();
Change to:
buf[i] = o->process();
-gabriel
More information about the Linux-audio-dev
mailing list