On 11/21/26 02:22, Thomas Koenig wrote:
Hello world,
I have looked at reassociation for a bit. Fortran allows expressions to
be reassociated, but parentheses must be honored. This we do (at least as
long as -fprotect-parens is in force).
The above is specifically stated in the standard.
F2023: 10.1.5.2.4(2)
Once the interpretation of a numeric intrinsic operation is
established, the processor may evaluate any mathematically
equivalent expression, provided that the integrity of parentheses
is not violated.
Note 2 on page 159, states a left-to-right evaluation order. So,
x = a + b + c + d from l-to-r is x = ((a + b) + c) + d. But,
Note 2 on page 163 shows allowed alternate forms. The RHS can
be evaluated as x = (a + b) + (c + d) or x = a + (b + c) + d.
There is also F2023:10.1.7.
It is not necessary for a processor to evaluate all of the
operands of an expression, or to evaluate entirely each
operand, if the value of the expression can be determined
otherwise.
But Fortran forbids reassociation
across different expressions or statements,
Can you point me to where the standard makes such a statement.
This suggests the standard forbids common subexpression elimination.
--
steve