https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86350

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Jun 28, 2018 at 04:59:53PM +0000, amonakov at gcc dot gnu.org wrote:
> 
> --- Comment #2 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
> The multiplication is optimized out under -ffinite-math-only -fno-signed-zeros
> (otherwise y can be NaN if bar returns infinity, for example).
> 
> Why is it ok to optimize out the call to bar even though it's impure?
> 

It can be optimized out because the Fortran Standard allows it.

  10.1.5.2.4 Evaluation of numeric intrinsic operations

  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.

  Two expressions of a numeric type are mathematically equivalent
  if, for all possible values of their primaries, their mathematical
  values are equal.  However, mathematically equivalent expressions
  of numeric type may produce different computational results.


  10.1.7 Evaluation of operands

  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.

Things may get delegate if the IEEE modules are in scope.

Reply via email to