From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7685C3858C50; Tue, 11 Apr 2023 10:16:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7685C3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681208174; bh=pDa2NXUpBvdAxtU9rroJhxyVuxmEkO7UHNYBgEMgXDI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=s2iXfaL8OxjDQgHY2Ym7RQEyyZE55UCE3XkmLkngqy25Rnb4E2KU1Y+4UkChTBMqJ UrLDGQw78G2DsL/RpMfXo6OqhgYu302b9e0QpEoUAwT5Tq3dYSfiMdwZpvBoxNoimi lQHmpzD/FeM/LFh7hmJKnrCGhWj1L/UiyEyBYDzs= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109443] missed optimization of std::vector access (Related to issue 35269) Date: Tue, 11 Apr 2023 10:16:13 +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: 13.0 X-Bugzilla-Keywords: alias, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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 cf_reconfirmed_on bug_status version component see_also 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=3D109443 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2023-04-11 Status|UNCONFIRMED |NEW Version|unknown |13.0 Component|tree-optimization |c++ See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D35269 --- Comment #6 from Richard Biener --- Well, but v.size () is not loop invariant. As Andrew says 'v' is passed by (const?) reference but the PTA solution doesn't exactly reflect this so we do think the call clobbers it: # USE =3D nonlocal escaped # CLB =3D nonlocal escaped f (_1); ... # PT =3D nonlocal escaped null _10 =3D MEM[(const struct vector *)v_5(D)].D.35644._M_impl.D.34955._M_fin= ish; # PT =3D nonlocal escaped null _11 =3D MEM[(const struct vector *)v_5(D)].D.35644._M_impl.D.34955._M_sta= rt; _12 =3D _10 - _11; _13 =3D _12 /[ex] 4; _14 =3D (long unsigned int) _13; if (i_8 < _14) goto ; [89.00%] so somehow the C++ handling of value-as-reference passing doesn't work (it should set TYPE_RESTRICT on the argument type used.=