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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to Richard Biener from comment #1)

> Not sure who is correct, or if both are and we can optimize the multiply
> by zero here (maybe in the context of a - b * 0.0 and a + b * 0.0).

The Fortran behavior is specified in Fortran 2023 (22-007r1.pdf) in


  10.1.5.2.1 Interpretation of numeric intrinsic operations
  ...
  Except for a value of type real or complex raised to an integer power,
  if the operands have different types or kind type parameters, the
  effect is as if each operand that differs in type or kind type
  parameter from those of the result is converted to the type and kind
  type parameter of the result before the operation is performed.  When
  a value of type real or complex is raised to an integer power, the
  integer operand need not be converted.

So, 
  __result_csmul = COMPLEX_EXPR <a, 0.0> * b;

is correct.  There is a caveat.  The Fortran standard does not mandate
the sign of zero.  If one wants to ignore exceptional values (i.e.,
0 * NaN, 0 * +-inf ), then one could annotate 0.0 to be +0.  But, that
will lead to so seriously flawed computations.

This should probably be closed with WONTFIX.

PS: -ffast-math might produce the optimized assembly.

Reply via email to