no noalias not negligible

Karl Heuer karl at haddock.ISC.COM
Tue May 24 09:48:14 AEST 1988


In article <1988May21.030207.25063 at light.uucp> bvs at light.UUCP (Bakul Shah) writes:
>In article <54080 at sun.uucp> dgh%dgh at Sun.COM (David Hough) writes:
>>Anyway there is no portable way in draft ANSI C to say "this pointers are
>>guaranteed to have no aliases".
>
>How about adding a test before the for loop?  Something like:
>#define overlap(x,y,n)    (!(x + n <= y || y + n <= x))
>	if (overlap(dx, dy, n))
>		return complain("overlapping arrays\n");
>
>Now a smart compiler can figure out that dx, dy don't overlap ...

The information is there, and a human reader can prove it, but I don't think
they make compilers that smart yet.

>note that in a sense this is an explicit translation of fortran's [rule]

Actually, a better translation might be
	assert(!overlap(dx, dy, n));
(though we'd need a slight change to the definition of assert to make this
useful for optimization).

>extern int daxpy(int n, double da, double dx[], double dy[])
>		/* call */if (!overlap(dx, dy, n));
>The syntax is unambiguous...

But it differs from currently-legal syntax only by the absence of a semicolon
separating the lines.  For that reason, i'd prefer something else.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list