From e665b52be99bd56dabeac030e5819e76b611f636 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 20 May 2024 11:51:07 -0400 Subject: [PATCH] 14.1.1-2 Resolves: RHEL-33402 --- gcc.spec | 7 +++- gcc14-pr101523.patch | 76 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 gcc14-pr101523.patch diff --git a/gcc.spec b/gcc.spec index d326248..0d6b4bd 100644 --- a/gcc.spec +++ b/gcc.spec @@ -4,7 +4,7 @@ %global gcc_major 14 # Note, gcc_release must be integer, if you want to add suffixes to # %%{release}, append them after %%{gcc_release} on Release: line. -%global gcc_release 1 +%global gcc_release 2 %global nvptx_tools_gitrev 9962793f41e016318dc5eca07ae602041cf526ff %global newlib_cygwin_gitrev d45261f62a15f8abd94a1031020b9a9f455e4eed %global _unpackaged_files_terminate_build 0 @@ -310,6 +310,7 @@ Patch8: gcc14-no-add-needed.patch Patch9: gcc14-Wno-format-security.patch Patch10: gcc14-rh1574936.patch Patch11: gcc14-d-shared-libphobos.patch +Patch12: gcc14-pr101523.patch Patch50: isl-rh2155127.patch @@ -910,6 +911,7 @@ so that there cannot be any synchronization problems. %patch -P10 -p0 -b .rh1574936~ %endif %patch -P11 -p0 -b .d-shared-libphobos~ +%patch -P12 -p1 -b .pr101523~ %patch -P50 -p0 -b .rh2155127~ touch -r isl-0.24/m4/ax_prog_cxx_for_build.m4 isl-0.24/m4/ax_prog_cc_for_build.m4 @@ -3630,6 +3632,9 @@ end %endif %changelog +* Thu May 16 2024 Marek Polacek 14.1.1-2 +- fix a combinatorial explosion in combine (PR rtl-optimization/101523) + * Wed May 8 2024 Jakub Jelinek 14.1.1-1 - update from releases/gcc-14 branch - GCC 14.1.0 release diff --git a/gcc14-pr101523.patch b/gcc14-pr101523.patch new file mode 100644 index 0000000..7ca8467 --- /dev/null +++ b/gcc14-pr101523.patch @@ -0,0 +1,76 @@ +Based on Richi's patch: + +~~ +The following avoids re-walking and re-combining the instructions +between i2 and i3 when the pattern of i2 doesn't change. + +Bootstrap and regtest running ontop of a reversal of +r14-9692-g839bc42772ba7a. + +It brings down memory use frmo 9GB to 400MB and compile-time from +80s to 3.5s. r14-9692-g839bc42772ba7a does better in both metrics +but has shown code generation regressions across acrchitectures. + + PR rtl-optimization/101523 + * combine.cc (try_combine): When the pattern of i2 doesn't + change do not re-start combining at i2 or an earlier insn which + had links or notes added. +~~ +But, since the patch affects code generation (for instance, +libstdc++-v3/src/c++17/floating_from_chars.o), we limit the bailing out +only when I2 hasn't been changed 1000x. I've measured how many times +at most is I2 unchanged during a bootstrap + regtest. +x86: 134 +aarch64: 736 (gimple-match-1.cc) +s390x: 635 (gimple-match-*) +ppc64le: 620 (gimple-match-*) +while certain pathological testcases trigger it more than 10,000 times. +With the limit in place this patch doesn't affect common code. + +--- a/gcc/combine.cc ++++ b/gcc/combine.cc +@@ -92,6 +92,11 @@ along with GCC; see the file COPYING3. If not see + #include "function-abi.h" + #include "rtlanal.h" + ++/* Number of times I2 didn't change in try_combine. Used to prevent a ++ combinatorial explosion. */ ++ ++static int combine_unchanged; ++ + /* Number of attempts to combine instructions in this function. */ + + static int combine_attempts; +@@ -1127,6 +1132,7 @@ combine_instructions (rtx_insn *f, unsigned int nregs) + return false; + + combine_attempts = 0; ++ combine_unchanged = 0; + combine_merges = 0; + combine_extras = 0; + combine_successes = 0; +@@ -4196,6 +4201,10 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, + adjust_for_new_dest (i3); + } + ++ bool i2_unchanged = false; ++ if (rtx_equal_p (newi2pat, PATTERN (i2))) ++ i2_unchanged = true; ++ + /* We now know that we can do this combination. Merge the insns and + update the status of registers and LOG_LINKS. */ + +@@ -4762,6 +4771,13 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, + combine_successes++; + undo_commit (); + ++ if (i2_unchanged) ++ { ++ if (combine_unchanged == 1000) ++ return i3; ++ ++combine_unchanged; ++ } ++ + rtx_insn *ret = newi2pat ? i2 : i3; + if (added_links_insn && DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (ret)) + ret = added_links_insn;