Article View: comp.lang.misc
Article #2168C vs. FORTRAN aliasing
From: Anton Rang
Date: Sun, 18 Nov 1990 21:01
Date: Sun, 18 Nov 1990 21:01
37 lines
1675 bytes
1675 bytes
Another thread I probably should avoid....
Suppose that I have a FORTRAN subroutine which takes two parameters
which it may modify, X and Y. Assume that the array A is declared
somehow; exactly how isn't important. Suppose you have the code:
SUBROUTINE BLAH(X,Y)
INTEGER X,Y
X = 3
Y = 2
IF (A(X) .EQ. 0) ...
Translating this to C, you get:
blah(int *x, int *y)
{
*x = 3;
*y = 2;
if (a(*x) == 0) ...
A compiler for FORTRAN can optimize the test to be A(3) since it
knows that the assignment to Y can never change X. A compiler for C,
in the absence of interprocedural aliasing information, cannot do the
same.
The interprocedural aliasing problem is NP-hard in the presence of
multi-level pointers or reference parameters (sorry, my refs are at
home right now, but if any cares e-mail me), and so various
approximation algorithms are used. For any approximation algorithm, I
can write (pathological) FORTRAN code which will result in worse code
being generated by the C compiler.
Anton
+---------------------------+------------------+-------------+
| Anton Rang (grad student) | rang@cs.wisc.edu | UW--Madison |
+---------------------------+------------------+-------------+
Technical Details
Message-ID:
<RANG.90Nov18160113@nexus.cs.wisc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!msuinfo!rangShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!msuinfo!rang From: rang@cs.wisc.edu (Anton Rang) Newsgroups: comp.lang.misc Subject: C vs. FORTRAN aliasing Message-ID: <RANG.90Nov18160113@nexus.cs.wisc.edu> Date: 18 Nov 90 21:01:13 GMT Sender: news@msuinfo.cl.msu.edu Organization: UW-Madison CS department Lines: 33