From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 915043857801; Fri, 16 Oct 2020 15:56:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 915043857801 From: "jamborm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/97456] [10/11 Regression] An incorrect optimization causes a function to always return the same value when using -flto Date: Fri, 16 Oct 2020 15:56:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jamborm at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2020 15:56:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97456 --- Comment #5 from Martin Jambor --- And indeed the following avoids the issue: diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index 2e54bbb917c..71ad7c18523 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -570,8 +570,10 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tr= ee value) /* Replace an anonymous base value with the variable from cvc_lookup. This should result in better debug info. */ if (SSA_NAME_VAR (ssa_name) - && (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value)= )) - && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name))) + && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)) + && (!SSA_NAME_VAR (value) + || (DECL_IGNORED_P (SSA_NAME_VAR (value)) + && !SSA_NAME_IS_DEFAULT_DEF (value)))) { comp =3D get_component_var (SSA_NAME_VAR (ssa_name), imag_p); replace_ssa_name_symbol (value, comp);=