Should I convert FORTRAN code to C?

Steven Ryan smryan at garth.UUCP
Sun Jul 3 07:06:35 AEST 1988


>>                 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.)



More information about the Comp.lang.c mailing list