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]

Re: pushing values to memory efficiently during rtl gen?


   From: Ken Raeburn <raeburn@cygnus.com>
   Date: 15 Sep 1998 11:55:29 -0400

   >       void foo(long double *a, long double *b, long double *c)
   >       {
   > 	*a = *b + *c;
   >       }
   > 
   > Ideally I'd like this to result in directly passing foo's pointer
   > parameters into the _Qp_add() libcall.

   What about aliasing issues -- if it's called as

	   foo (&accum, &accum, &x)

   ?  Can some bits of the output be written before some bits of the
   input are read (for the last time)?  Is it safe not to use a temporary
   for the output?  The definition of foo clearly requires it to behave
   as if there is a temporary; your description of _Qp_add doesn't
   indicate how it behaves.

Although it is not stated explicitly in the ABI, I believe the
intention is that an implementation will read the inputs first, then
write the output at the end.  All implementations I know work like:

	_Qp_add(c, a, b)
	{
		UNPACK(a, local_a)
		UNPACK(b, local_b)
		do_operation(local_c, local_a, local_c)
		PACK(c, local_c)
	}

So your aliasing issue would work out ok.

And when I do specify such operations as a libcall, does not the
implied semantics of a libcall say something about these cases?

Actually, it is interesting, what should be the semantics of a libcall
be when scalar arguments are passed via ptrs to them?

Later,
David S. Miller
davem@dm.cobaltmicro.com



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