(j3.2006) mathematical equivalence and MATMUL

Robert Corbett robert.corbett
Mon Oct 24 23:33:39 EDT 2016


A user recently complained about an "optimization"
performed by Oracle Developer Studio Fortran.  The
user's expression

       2.0 * MATMUL(A, B)

was "optimized" into the mathematically equivalent
expression

       MATMUL(2.0*A, B)

Moving the multiplication into the first argument
resulted in an overflow that would not have occurred
for the original expression.

Is the optimization shown allowed by the Fortran standard?

If the integrity of parentheses rule applies to the
parentheses around an actual argument list, the
optimization shown would be prohibited.  Many
desirable optimizations would also be prohibited.

If the original expression had been written as

       2.0 * (MATMUL(A, B))

would the optimization be allowed by the Fortran
standard?  I think not, but Oracle Developer Studio
Fortran still does the optimization in this case.

Robert Corbett



More information about the J3 mailing list