public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* adding -fnoalias ... would a patch be accepted ?
@ 2010-01-05 13:40 torbenh
  2010-01-05 13:46 ` Richard Guenther
  0 siblings, 1 reply; 15+ messages in thread
From: torbenh @ 2010-01-05 13:40 UTC (permalink / raw)
  To: gcc


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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-01-06 17:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-05 13:40 adding -fnoalias ... would a patch be accepted ? torbenh
2010-01-05 13:46 ` Richard Guenther
2010-01-05 15:02   ` torbenh
2010-01-05 16:42     ` Tim Prince
2010-01-05 15:03   ` torbenh
2010-01-05 15:27     ` Richard Guenther
2010-01-05 16:39       ` torbenh
2010-01-06 13:27         ` Richard Guenther
2010-01-06 15:26           ` torbenh
2010-01-06 15:45             ` Richard Guenther
2010-01-06 15:49               ` Richard Guenther
2010-01-06 16:48                 ` torbenh
2010-01-06 17:37               ` torbenh
2010-01-06 15:45             ` torbenh
2010-01-06 15:51               ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).