From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E80B3858C3A; Fri, 31 Dec 2021 14:14:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E80B3858C3A From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/103875] Dead writes are not optimized out Date: Fri, 31 Dec 2021 14:14:41 +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: 11.2.1 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: everconfirmed component bug_severity bug_status cf_reconfirmed_on cc 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, 31 Dec 2021 14:14:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103875 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Component|middle-end |ipa Severity|normal |enhancement Status|UNCONFIRMED |NEW Last reconfirmed| |2021-12-31 CC| |marxin at gcc dot gnu.org --- Comment #1 from Andrew Pinski --- The inliner removes the clobber in this case it seems: We have: void foo::pop (struct foo * const this) { long unsigned int _1; long unsigned int _2; long unsigned int _3; value_type * _4; : _1 =3D this_6(D)->size; _2 =3D _1 + 18446744073709551615; this_6(D)->size =3D _2; _3 =3D this_6(D)->size; _4 =3D &this_6(D)->data[_3]; *_4 =3D{v} {CLOBBER}; return; } void use_foo (struct foo & f) { int _1; int _2; value_type & _6; : _6 =3D foo::back (f_4(D)); _1 =3D *_6; _2 =3D _1 * 42; *_6 =3D _2; foo::pop (f_4(D)); return; } And then foo::pop (and back) gets inlined we get: void use_foo (struct foo & f) { value_type & D.2143; int _1; int _2; long unsigned int _5; value_type & _6; long unsigned int _9; long unsigned int _10; long unsigned int _11; value_type & _12; value_type & _13; : _10 =3D f_4(D)->size; _11 =3D _10 + 18446744073709551615; _12 =3D &f_4(D)->data[_11]; _13 =3D _12; _6 =3D _13; _1 =3D *_6; _2 =3D _1 * 42; *_6 =3D _2; _5 =3D f_4(D)->size; _9 =3D _5 + 18446744073709551615; f_4(D)->size =3D _9; return; }=