From 6ff4c6c93f5468fe89de5e2e73c98808fb1b5e03 Mon Sep 17 00:00:00 2001 From: zhaoshujian Date: Tue, 6 Jun 2023 23:38:31 +0800 Subject: [PATCH 1/2] To resolve the spec 548 fluctuation problem, revert the GCC commit and 0037 patch --- ...variant-Don-t-move-cold-bb-instructi.patch | 83 ------------------- ...PEC-.548-fluctuation-problem-revert-.patch | 26 ++++++ gcc.spec | 12 ++- 3 files changed, 35 insertions(+), 86 deletions(-) delete mode 100644 0037-Backport-loop-invariant-Don-t-move-cold-bb-instructi.patch create mode 100644 0089-To-resolve-the-SPEC-.548-fluctuation-problem-revert-.patch diff --git a/0037-Backport-loop-invariant-Don-t-move-cold-bb-instructi.patch b/0037-Backport-loop-invariant-Don-t-move-cold-bb-instructi.patch deleted file mode 100644 index b30030e..0000000 --- a/0037-Backport-loop-invariant-Don-t-move-cold-bb-instructi.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 897d637aec3b077eb9ef95b2f4a5f7656e36ebd6 Mon Sep 17 00:00:00 2001 -From: benniaobufeijiushiji -Date: Wed, 15 Jun 2022 11:33:03 +0800 -Subject: [PATCH 03/12] [Backport] loop-invariant: Don't move cold bb - instructions to preheader in RTL - -Reference: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=dc1969dab392661cdac1170bbb8c9f83f388580d - -When inner loop is unlikely to execute, loop invariant motion would move -cold instrcutions to a hotter loop. This patch adds profile count checking -to fix the problem. ---- - gcc/loop-invariant.c | 17 ++++++++++++++--- - gcc/testsuite/gcc.dg/loop-invariant-2.c | 20 ++++++++++++++++++++ - 2 files changed, 34 insertions(+), 3 deletions(-) - create mode 100644 gcc/testsuite/gcc.dg/loop-invariant-2.c - -diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c -index 37ae6549e..24b9bcb11 100644 ---- a/gcc/loop-invariant.c -+++ b/gcc/loop-invariant.c -@@ -1184,9 +1184,21 @@ find_invariants_insn (rtx_insn *insn, bool always_reached, bool always_executed) - call. */ - - static void --find_invariants_bb (basic_block bb, bool always_reached, bool always_executed) -+find_invariants_bb (class loop *loop, basic_block bb, bool always_reached, -+ bool always_executed) - { - rtx_insn *insn; -+ basic_block preheader = loop_preheader_edge (loop)->src; -+ -+ /* Don't move insn of cold BB out of loop to preheader to reduce calculations -+ and register live range in hot loop with cold BB. */ -+ if (!always_executed && preheader->count > bb->count) -+ { -+ if (dump_file) -+ fprintf (dump_file, "Don't move invariant from bb: %d out of loop %d\n", -+ bb->index, loop->num); -+ return; -+ } - - FOR_BB_INSNS (bb, insn) - { -@@ -1215,8 +1227,7 @@ find_invariants_body (class loop *loop, basic_block *body, - unsigned i; - - for (i = 0; i < loop->num_nodes; i++) -- find_invariants_bb (body[i], -- bitmap_bit_p (always_reached, i), -+ find_invariants_bb (loop, body[i], bitmap_bit_p (always_reached, i), - bitmap_bit_p (always_executed, i)); - } - -diff --git a/gcc/testsuite/gcc.dg/loop-invariant-2.c b/gcc/testsuite/gcc.dg/loop-invariant-2.c -new file mode 100644 -index 000000000..df3d84585 ---- /dev/null -+++ b/gcc/testsuite/gcc.dg/loop-invariant-2.c -@@ -0,0 +1,20 @@ -+/* { dg-do compile } */ -+/* { dg-options "-O2 -fdump-rtl-loop2_invariant" } */ -+ -+volatile int x; -+void -+bar (int, char *, char *); -+void -+foo (int *a, int n, int k) -+{ -+ int i; -+ -+ for (i = 0; i < n; i++) -+ { -+ if (__builtin_expect (x, 0)) -+ bar (k / 5, "one", "two"); -+ a[i] = k; -+ } -+} -+ -+/* { dg-final { scan-rtl-dump "Don't move invariant from bb: .*out of loop" "loop2_invariant" } } */ --- -2.27.0.windows.1 - diff --git a/0089-To-resolve-the-SPEC-.548-fluctuation-problem-revert-.patch b/0089-To-resolve-the-SPEC-.548-fluctuation-problem-revert-.patch new file mode 100644 index 0000000..836197a --- /dev/null +++ b/0089-To-resolve-the-SPEC-.548-fluctuation-problem-revert-.patch @@ -0,0 +1,26 @@ +From 962eda7f0336c883c52c33a9b61a19f7e80ea9e2 Mon Sep 17 00:00:00 2001 +From: root +Date: Tue, 6 Jun 2023 22:29:03 +0800 +Subject: [PATCH] To resolve the SPEC .548 fluctuation problem, revert GCC + commit 835d50c66aa5bde2f354a6e63a2afa7d2f76a05a + +--- + gcc/config/aarch64/aarch64.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 85dbd3898..116b4b8ca 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -12726,7 +12726,7 @@ cost_plus: + } + + if (GET_MODE_CLASS (mode) == MODE_INT +- && (aarch64_plus_immediate (op1, mode) ++ && ((CONST_INT_P (op1) && aarch64_uimm12_shift (INTVAL (op1))) + || aarch64_sve_addvl_addpl_immediate (op1, mode))) + { + *cost += rtx_cost (op0, mode, PLUS, 0, speed); +-- +2.33.0 + diff --git a/gcc.spec b/gcc.spec index cfcc437..8024cc7 100644 --- a/gcc.spec +++ b/gcc.spec @@ -61,7 +61,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: 22 +Release: 23 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD URL: https://gcc.gnu.org @@ -147,7 +147,6 @@ Patch33: 0033-AutoFdo-Fix-memory-leaks-in-autofdo-and-autoprefetch.patch Patch34: 0034-Backport-sanitizer-Fix-asan-against-glibc-2.34-PR100.patch Patch35: 0035-ccmp-Add-another-optimization-opportunity-for-ccmp-i.patch Patch36: 0036-StructReorg-Refactoring-reorder-fields-to-struct-lay.patch -Patch37: 0037-Backport-loop-invariant-Don-t-move-cold-bb-instructi.patch Patch38: 0038-DFE-Add-Dead-Field-Elimination-in-Struct-Reorg.patch Patch39: 0039-Backport-ipa-sra-Fix-thinko-when-overriding-safe_to_.patch Patch40: 0040-Backport-ifcvt-Allow-constants-for-noce_convert_mult.patch @@ -197,6 +196,7 @@ Patch85: 0085-loop-distribution-Bugfix-for-loop-distribution.patch Patch86: 0086-semi-relayout-Bugfix-for-struct-semi-relayout.patch Patch87: 0087-Backport-tree-optimization-97238-fix-typo-causing-IC.patch Patch88: 0088-Backport-fix-typo-causing-ICE.patch +Patch89: 0089-To-resolve-the-SPEC-.548-fluctuation-problem-revert-.patch %global gcc_target_platform %{_arch}-linux-gnu @@ -689,7 +689,6 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch34 -p1 %patch35 -p1 %patch36 -p1 -%patch37 -p1 %patch38 -p1 %patch39 -p1 %patch40 -p1 @@ -739,6 +738,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch86 -p1 %patch87 -p1 %patch88 -p1 +%patch89 -p1 %build @@ -2895,3 +2895,9 @@ end - ID:NA - SUG:NA - DESC:Init GCC 10.3.0 repository + +*Tue Jun Zhao Shujian - 10.3.1-23 +- Type:Spec +- ID:NA +- SUG:NA +- DESC: To resolve the spec 548 fluctuation problem, revert GCC commit. -- Gitee From 1c2df6790d7d86fdbebf0e7ee8d513a5b16f6eb9 Mon Sep 17 00:00:00 2001 From: zhaoshujian Date: Wed, 7 Jun 2023 11:01:34 +0800 Subject: [PATCH 2/2] [Revert] Revert GCC commit and 0037 patch to resolve spec 548 fluctuation prooblem --- gcc.spec | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc.spec b/gcc.spec index 8024cc7..bb644a7 100644 --- a/gcc.spec +++ b/gcc.spec @@ -2762,6 +2762,12 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Wed Jun 07 2023 Zhao Shujian - 10.3.1-23 +- Type:Spec +- ID:NA +- SUG:NA +- DESC: To resolve the spec 548 fluctuation problem, revert GCC commit. + * Sun Apr 23 2023 Xiong Zhou - 10.3.1-22 - Type:Sync - ID:NA @@ -2896,8 +2902,3 @@ end - SUG:NA - DESC:Init GCC 10.3.0 repository -*Tue Jun Zhao Shujian - 10.3.1-23 -- Type:Spec -- ID:NA -- SUG:NA -- DESC: To resolve the spec 548 fluctuation problem, revert GCC commit. -- Gitee