From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C6F313858D35; Tue, 4 Aug 2020 11:44:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6F313858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596541459; bh=eaJdV2bpic2XPI8OhT5tfuTOUSHyD55TtBHI5rV//sg=; h=From:To:Subject:Date:From; b=MnTuot35vtQY7C6A1HWot3rpFspEnDL8mT/s75sKxastPwnz/W7wbs6n+WhfLz/Xa ClhPVp8KO96b6g/edgVQbizH1mwihfHTjgUaLaULizrPrkMyMzaDP1DFA+Tx/61r2t NVVjdc6Xj8XozvILSBq4NFq2WQkOymGoY71uQyew= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/96457] New: PRE gets confused by punned load handling Date: Tue, 04 Aug 2020 11:44:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Tue, 04 Aug 2020 11:44:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96457 Bug ID: 96457 Summary: PRE gets confused by punned load handling Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- int flag; union { double f; unsigned long long i; } u; void foo(); unsigned long long i; unsigned long long test () { double f =3D 0.; if (flag) { foo (); f =3D u.f; } else i =3D u.i; f =3D u.f + f; return f; } here we fail to PRE the load of u.f because PHI translation to the else path fails since we run into /* If we'd have to convert things we would need to validate if we can insert the translated expression. So fail here for now - we cannot insert an alias with a different type in the VN tables either, as that would assert. */ if (result && !useless_type_conversion_p (ref->type, TREE_TYPE (result= ))) return NULL; because we found a value for u.f there, that of u.i (because we value-number them the same). If one replaces 'i =3D u.i;' with 'foo ();' we appropriate= ly insert a load from u.f in the else path and remove the partial redundancy.=