Xref: utzoo comp.lang.fortran:869 comp.lang.c:11090 Path: utzoo!attcan!uunet!husc6!mailrus!ames!joyce!sri-unix!garth!smryan From: smryan@garth.UUCP (Steven Ryan) Newsgroups: comp.lang.fortran,comp.lang.c Subject: Re: Should I convert FORTRAN code to C? Summary: Fortran Follies. Message-ID: <857@garth.UUCP> Date: 2 Jul 88 21:06:35 GMT References: <20454@beta.lanl.gov> <6067@megaron.arizona.edu> Reply-To: smryan@garth.UUCP (Steven Ryan) Organization: INTERGRAPH (APD) -- Palo Alto, CA Lines: 32 >> An early step in the compiler usually turns the array >> reference into a linear function on the indices - this throws out the >> dependency information. > >This is not true. How can information be lost by changing "a[i]" to >"*(a+i)"? In fact at least one very fancy FORTRAN compiler converts >array references to exactly that form to extract dependency >information that is difficult to recognize otherwise. [at two fortran compilers--the vectorising compiler I worked on also operated on an affine function of the subscripts.] The C subscript, if taken literally, does lose dependency information. Strict C parse tree possible Fortran parse tree convert-*-to-variable subscript | / \ integer-add symbol: a integer-multiply / \ / \ symbol: a integer-multiply element-size i / \ element-size i By having an explicit subscript node, a Fortran optimiser can easily access the array spans for each dimension, necessary for vectorisation. It also simplifies determining what region is referenced or defined, necessary for common subexpressions. ------------------------------------ USA - home of the modern revolution. (tho we'd just soon fergit it.)