From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 01BA13858D32; Mon, 17 Oct 2022 15:14:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01BA13858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666019644; bh=hf7wSvGhrQZDPQYlwNu3Y134s9NtqDyRsXpmHKQ29Ps=; h=From:To:Subject:Date:In-Reply-To:References:From; b=j9XrEKnGQj3DPR1Jw1kB4O84BzIbqDA6GLd10WO+nw0/yLb+nBqruTkS7pmzQIqDj CGJYu/zrfJRg8ETJ3EDqlwT4vAOIVVoKv5Q13zMiHq3VIAgShCEW5qViaM9YXZIA1K WCQLskpE3LrRSu/LY8xo39R3aVJJujxjKpFW8338= From: "kargl at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/107294] Missed optimization: multiplying real with complex number in Fortran (only) Date: Mon, 17 Oct 2022 15:14:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: kargl at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107294 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,=20 __result_csmul =3D COMPLEX_EXPR * 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.=