From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3CD903858410; Wed, 17 Nov 2021 01:54:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3CD903858410 From: "luoxhu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug testsuite/103270] [12 regression] gcc.dg/vect/pr96698.c inner loop turned from hot to cold after r12-4526 Date: Wed, 17 Nov 2021 01:54:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: testsuite X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: luoxhu 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: 12.0 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 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: Wed, 17 Nov 2021 01:54:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103270 --- Comment #2 from luoxhu at gcc dot gnu.org --- (In reply to Richard Biener from comment #1) > So you say this is a problem with loop header copying, that would mean the > issue is really latent and general, no? Header copying uses > gimple_duplicate_sese_region and has no own profile updating. I guess its > profile updating code isn't designed to cope with copying a region with > "side"-entries (we are ignoring the backedge here). Not sure if we can > somehow generally handle those (maybe we can learn from tracer or threader > here). >=20 > Honza? Yes, it seems to be a general issue in gimple_duplicate_sese_region, the in= ner loop cfg was: 8 | 3<--=20 | \ | 5 4=20=20 And it is modified by ch_base::copy_headers->gimple_duplicate_sese_region t= o( entry edge is 8->3, exit edge is 3->4): 8 | 12 | 4<--=20 | | 3--- | 5 bb 12 is copied block from bb 3 as new preheader, bb 3 is rotated to be new exit of the loop, bb 3 and bb 12 are adjusted count to "total_count - entry_count" (354334800) and "entry_count"(719407024), at last bb 3 and bb 4 will be merged to one block by gimple_merge_blocks later by TODO_cleanup_cfg with much smaller count than preheader. gimple_duplicate_sese_region: if (total_count.initialized_p () && entry_count.initialized_p ()) { scale_bbs_frequencies_profile_count (region, n_region, total_count - entry_count, total_count); scale_bbs_frequencies_profile_count (region_copy, n_region, entry_cou= nt, total_count); } Obviously, region of bb 3's profile count shouldn't be decreased from "total_count" to "total_count - entry_count", it executes at every executio= n of the loop. Simply adjust it back to total_count and region_copy to entry_co= unt will cause some other cases fail. And at the moment edge 3->4 is still not a backedge now?=