From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2F1503847700; Wed, 3 Apr 2024 10:58:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F1503847700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712141891; bh=PEgi6rCni4oIrIC8htiLfxqJ6PAMh3PvJY8uJF36TqI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=r1nZuY9K+RxbNG5iPXi39A4+gT7ZFViMSlRvv+yrTQsrT42I2irCgfMLdtvO8e7Fk sYmIzmc3xEgDspU+UEYFRyzLvWk4f23M6bMeElHBicUcN1BMtXxlBtdA18xIW3iUFh Bvdit5MbmrpQxb8o7Y2af+V3FgV+MO55s0NplyCk= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/101523] Huge number of combine attempts Date: Wed, 03 Apr 2024 10:58:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization 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: RESOLVED X-Bugzilla-Resolution: FIXED 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 #53 from Richard Biener --- So just to recap, with reverting the change and instead doing diff --git a/gcc/combine.cc b/gcc/combine.cc index a4479f8d836..ff25752cac4 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -4186,6 +4186,10 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i= 1, rtx_insn *i0, adjust_for_new_dest (i3); } + bool i2_unchanged =3D false; + if (rtx_equal_p (newi2pat, PATTERN (i2))) + i2_unchanged =3D true; + /* We now know that we can do this combination. Merge the insns and update the status of registers and LOG_LINKS. */ @@ -4752,6 +4756,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, combine_successes++; undo_commit (); + if (i2_unchanged) + return i3; + rtx_insn *ret =3D newi2pat ? i2 : i3; if (added_links_insn && DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (ret)) ret =3D added_links_insn; combine time is down from 79s (93%) to 3.5s (37%), quite a bit more than with the currently installed patch which has combine down to 0.02s (0%). But notably peak memory use is down from 9GB to 400MB (installed patch 340M= B). That was with a cross from x86_64-linux and a release checking build. This change should avoid any code generation changes, I do think if the pattern doesn't change what distribute_notes/links does should be a no-op even to I2 so we can ignore added_{links,notes}_insn (not ignoring them only provides a 50% speedup). I like the 0% combine result of the installed patch but the regressions observed probably mean this needs to be defered to stage1.=