From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 55F403858D32; Wed, 1 Nov 2023 15:51:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55F403858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698853892; bh=VIFO8/X/e0lDYhimoatsku1GysvaaOFOBwhSJErakpc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=uQVxQuuHoDd+GOVOR/US3bmzye18vr1SHU/YsOxcNOFnPny2z562OENn0lesoS5jj /hkmCLZjlGbZX3XtHMqJpRl3YOf+6uJKl52DVpkloZuhpunKxNGSt4s3q7063AH0it rLR7RFPtl5RBRfgbttBNBuTHXKNSg+2FCRaLw8zE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112335] missed optimization on reset and assign unique_ptr Date: Wed, 01 Nov 2023 15:51:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 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=3D112335 --- Comment #1 from Andrew Pinski --- __old_p_6 =3D MEM[(struct s * &)ps1_2(D)]; MEM[(struct s * &)ps1_2(D)] =3D 0B; if (__old_p_6 !=3D 0B) goto ; [53.47%] else goto ; [46.53%] [local count: 574129752]: s::~s (__old_p_6); operator delete (__old_p_6, 1); [local count: 1073741824]: __p_4 =3D MEM[(struct s * &)ps2_3(D)]; MEM[(struct s * &)ps2_3(D)] =3D 0B; __old_p_5 =3D MEM[(struct s * &)ps1_2(D)]; Well s::~s could touch the reference std::unique_ptr (ps1). So this could in theory be an invalid optimization. I am not sure if that is the only issue here though.=