From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4AFCE385840E; Fri, 22 Mar 2024 12:38:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4AFCE385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711111091; bh=Pqnzc52+yW6/bQj8RnwIpokqa0lAxXWwnDRKn1vdoYI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=idH5FK5rqt6vFuo7tzNJXFSoPDakq4mLmXqGH4VnUiCFQMXxiLSZYH8xI/n7pAjcJ b8AmxzLQsifC/gLix9DfseLpku+oy1RO/yJZQj1y5fCPDeDghmVG20UtFSqC0O3nC/ SQGagFZdnAneEd8M9l9Q3CIkWFMXpELrUi4L3TK8= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/101523] Huge number of combine attempts Date: Fri, 22 Mar 2024 12:38:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: compile-time-hog, memory-hog 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: segher 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=3D101523 --- Comment #48 from Richard Biener --- So another "simple" way is to keep the redundant insn walking ("it's O(1)")= but remember processsed insns and only re-process those we mark as such. There might be a free "visited" bit on rtx_insn, who knows, the following u= ses a bitmap to track this. Likely where we set/update added_links_insn we should mark insns for re-processing. A worklist, if it were to be processed in instruction order, would need to be kept ordered and DF docs say DF_INSN_LUID isn't to be trusted after adding/removing insns. diff --git a/gcc/combine.cc b/gcc/combine.cc index a4479f8d836..c2f04e6b86e 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -1106,6 +1106,8 @@ insn_a_feeds_b (rtx_insn *a, rtx_insn *b) return false; } ^L +static bitmap processed; + /* Main entry point for combiner. F is the first insn of the function. NREGS is the first unused pseudo-reg number. @@ -1211,6 +1213,8 @@ combine_instructions (rtx_insn *f, unsigned int nregs) setup_incoming_promotions (first); last_bb =3D ENTRY_BLOCK_PTR_FOR_FN (cfun); int max_combine =3D param_max_combine_insns; + processed =3D BITMAP_ALLOC (NULL); + bitmap_tree_view (processed); FOR_EACH_BB_FN (this_basic_block, cfun) { @@ -1231,6 +1235,7 @@ combine_instructions (rtx_insn *f, unsigned int nregs) label_tick_ebb_start =3D label_tick; last_bb =3D this_basic_block; + bitmap_clear (processed); rtl_profile_for_bb (this_basic_block); for (insn =3D BB_HEAD (this_basic_block); insn !=3D NEXT_INSN (BB_END (this_basic_block)); @@ -1240,6 +1245,9 @@ combine_instructions (rtx_insn *f, unsigned int nregs) if (!NONDEBUG_INSN_P (insn)) continue; + if (!bitmap_set_bit (processed, INSN_UID (insn))) + continue; + while (last_combined_insn && (!NONDEBUG_INSN_P (last_combined_insn) || last_combined_insn->deleted ())) @@ -1427,6 +1435,7 @@ retry: ; } } + BITMAP_FREE (processed); default_rtl_profile (); clear_bb_flags (); @@ -4758,6 +4767,14 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i= 1, rtx_insn *i0, if (added_notes_insn && DF_INSN_LUID (added_notes_insn) < DF_INSN_LUID (ret)) ret =3D added_notes_insn; + bitmap_clear_bit (processed, INSN_UID (i3)); + if (newi2pat) + bitmap_clear_bit (processed, INSN_UID (newi2pat)); + if (added_links_insn) + bitmap_clear_bit (processed, INSN_UID (added_links_insn)); + if (added_notes_insn) + bitmap_clear_bit (processed, INSN_UID (added_notes_insn)); + return ret; } ^L=