From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E0D0B3858D35; Tue, 23 May 2023 16:09:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0D0B3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684858185; bh=ktFiwEyZVG+RCi+jkhffeWQYYzP5QbQACeqeUsHRDGk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=up/CV2dJiprrqAnKa7E0vXXoIkWzNpRwQ03Jmo+GjhJ0gDTJQKIJ+UJtBQLXzPrVs r+ZhguMfN7izS+6NQ8jJsMgy3c6fr3uGiBywHGcQiEZBOIn6SF0wrWReVOiX3MQVNN ZQcpZ+Guve/Uw8xN93OscXnufx29ejPmYhjHAdfY= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109945] Escape analysis hates copy elision: different result with -O1 vs -O2 Date: Tue, 23 May 2023 16:09:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component cf_reconfirmed_on cc bug_status assigned_to everconfirmed version 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=3D109945 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |tree-optimization Last reconfirmed| |2023-05-23 CC| |jakub at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org Ever confirmed|0 |1 Version|unknown |14.0 --- Comment #1 from Richard Biener --- ESCAPED, points-to vars: { } intD.9 mainD.2827 () { intD.9 w$iD.2845; intD.9 iD.2831; struct WidgetD.2773 wD.2829; intD.9 _1;=20 boolD.2740 _2; intD.9 _7;=20 : # USE =3D nonlocal=20=20 # CLB =3D nonlocal escaped wD.2829 =3D makeD.2813 (); [return slot optimization] w$i_9 =3D wD.2829.iD.2778; i_5 =3D w$i_9; # USE =3D nonlocal escaped # CLB =3D nonlocal escaped gD.2825 (); _1 =3D w$i_9; _2 =3D _1 =3D=3D i_5; _7 =3D (intD.9) _2; wD.2829 =3D{v} {CLOBBER(eol)}; return _7; } so indeed GCC points-to doesn't consider wD.2829 =3D makeD.2813 (); [return slot optimization] as escape point for the return. We have /* And if we applied NRV the address of the return slot escapes as well. = */ if (gimple_call_return_slot_opt_p (stmt) && gimple_call_lhs (stmt) !=3D NULL_TREE && TREE_ADDRESSABLE (TREE_TYPE (gimple_call_lhs (stmt)))) { but in this case the type is not TREE_ADDRESSABLE. I'm not sure why this check is here. Removing it fixes the issue. A !is_gimple_reg (lhs) check may be a substitute in case we can get stale return-slot-opt flags?=