From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B5E53858D39; Sun, 26 Dec 2021 23:17:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B5E53858D39 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/79349] unused std::string is not optimized away in presense of a call Date: Sun, 26 Dec 2021 23:17:01 +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: 7.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia 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: component 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: Sun, 26 Dec 2021 23:17:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D79349 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Component|libstdc++ |tree-optimization --- Comment #5 from Andrew Pinski --- here is the current IR (with -fno-exceptions) at -O3: MEM[(struct basic_string *)&s] =3D{v} {CLOBBER}; MEM[(struct _Alloc_hider *)&s] =3D{v} {CLOBBER}; MEM[(struct _Alloc_hider *)&s]._M_p =3D &s.D.26433._M_local_buf; __builtin_memcpy (&s.D.26433._M_local_buf, "abc", 3); s._M_string_length =3D 3; MEM[(char_type &)&s + 19] =3D 0; foo (); _3 =3D s._M_dataplus._M_p; if (&s.D.26433._M_local_buf !=3D _3) goto ; [53.47%] else goto ; [46.53%] [local count: 574129753]: _7 =3D s.D.26433._M_allocated_capacity; _8 =3D _7 + 1; operator delete (_3, _8); for some reason GCC thinks foo can modify s so the load for s._M_dataplus._= M_p is not be optimized to just &s.D.26433._M_local_buf=