This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

adding -fnoalias ... would a patch be accepted ?


hi...

i am new to this list. 

i am trying to something like:

struct Ramp
{
    float phase;
    inline float process() { return phase++; }
} ramp;

void fill_buffer( float *buf, size_t nframes )
{
	for( size_t i=0; i<nframes; i++ )
		buf[i] = ramp.process()
}

the goal is to chain several of such Ramp structs together via
templates. so that i can model dsp graphs, but have it all inlined into
the loop.

however the stores to phase cant be moved out of the loop due to
aliasing. but that is one of the points to do this whole exercise.

this simple case can be optimized when i use -fargument-noalias-anything
and:

void fill_buffer( float *buf, size_t nframes )
{
	for( size_t i=0; i<nframes; i++ )
		*(buf++) = ramp.process()
}

but things start to break again, when i add:

struct Sample
{
	unsigned int pos;
	float *sample;
	inline float process() { return sample[pos++]; }
}


__restrict__ is of no help here. which leads me to the question whats
the point of a restricted this pointer ? members of structs arent
unaliased by a __restrict__ pointer to the struct. 

my favourite solution would be __noalias__ ... msvc has that. 
but -fnoalias would make me happy too.

i havent read much of the gcc code yet, so i am not sure what i need to
patch. 

refs_may_alias_p_1() is my current bet though.

-- 
torben Hohn


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]