On Wed, Jun 27, 2018 at 08:15:13AM +0200, Jakub Jelinek wrote: > > I think best would be to change the above to > code = TRUTH_AND_EXPR and code = TRUTH_OR_EXPR and have some > non-default aggressive optimization option that would optimize > away in the FE impure function calls from those operands if > one operand is cheap to evaluate and another one > contains function calls, by optimizing it into TRUTH_{AND,OR}IF_EXPR where > the cheap operand is the first operand and operand with function calls is > the second.
I completely disagree. The Fortran standards (ie., F95, F2003, F2008, and F2018) clearly state that the operands of an expression need not be evaluate if the result of an expression can be determined. If an option is introduced, then it should be -fforce-evaluation. The standards also state that the order of evaluation is unspecified, which permits the optimization introduced by Thomas to provide the lack of symmetry that Janus observed in '.false. .and. check()' and 'check() .and. .false.' should be committed. -- Steve