NOT Educating FORTRAN programmers to use C

Chris Torek chris at mimsy.umd.edu
Fri Jan 12 15:07:54 AEST 1990


In article <14191 at lambda.UUCP> jlg at lambda.UUCP (Jim Giles) writes:
-In a previous article I made the incorrect statement that the number
-of machines which can be well optimized in the presence of pointers
-is growing narrow.  The fact is that the set of such machines is zero
-(at least, to the best of my knowledge).  Consider the following code:
-
-  z=1;
-  *a=2;
-  *b=1;
-
-If you could tell that a and b were not aliased (to each other
-or to z), the the generated code would be to set a register to
-one, store z, store b, increment, and store a.

1) you *can* tell aliasing (automatically, in the compiler) in many cases
   (not all).

-However, if you
-can't detect aliasing the sequence must be in the order given.
-On all machines I know, this would require at least one more
-instruction - so even on a RISC machine with no pipelining or
-vectorization to worry about this code would be 20% slower because
-of the possibility of aliasing.

2) even when you cannot, this is false.  The generated code
   would be `store 2 in register z', `store register z in *b',
   `decreemnt register z', `store register z in *a'.

-If these were arrays and this
-sequence of code were in an inner loop, this slowdown could
-strongly effect the whole code's performance.

... and you would simply write

	#pragma nonintersecting a, b

or something similar.

I refuse to read or respond to anything futher from jlg (at least for a few
weeks); it is bad for my blood pressure.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list