[Revert] Revert GCC commit and 0037 patch to resolve spec 548 problem

(cherry picked from commit ae197ee8233b46c270c0e24d01aa5b020d836a2a)
This commit is contained in:
wangding16 2023-06-14 12:49:02 +08:00 committed by openeuler-sync-bot
parent fd2d0bae44
commit 65170ff813
3 changed files with 35 additions and 86 deletions

View File

@ -1,83 +0,0 @@
From 897d637aec3b077eb9ef95b2f4a5f7656e36ebd6 Mon Sep 17 00:00:00 2001
From: benniaobufeijiushiji <linda7@huawei.com>
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

View File

@ -0,0 +1,26 @@
From 962eda7f0336c883c52c33a9b61a19f7e80ea9e2 Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
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

View File

@ -61,7 +61,7 @@
Summary: Various compilers (C, C++, Objective-C, ...)
Name: gcc
Version: %{gcc_version}
Release: 34
Release: 35
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
@ -209,6 +208,7 @@ Patch97: 0097-libquadmath-refactor-Enable-libquadmath-on-kunpeng.patch
Patch98: 0098-AArch64-Rewrite-the-tsv110-option.patch
Patch99: 0099-Struct-Reorg-Add-escape-propagate-on-external-functi.patch
Patch100: 0100-PGO-kernel-Add-fkernel-pgo-option-to-support-PGO-ker.patch
Patch101: 0101-To-resolve-the-SPEC-.548-fluctuation-problem-revert-.patch
%global gcc_target_platform %{_arch}-linux-gnu
@ -701,7 +701,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
@ -763,6 +762,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
%patch98 -p1
%patch99 -p1
%patch100 -p1
%patch101 -p1
%build
@ -2787,6 +2787,12 @@ end
%doc rpm.doc/changelogs/libcc1/ChangeLog*
%changelog
* Wed Jun 14 2023 Wang Ding <wangding16@huawei.com> - 10.3.1-35
- Type:Spec
- ID:NA
- SUG:NA
- DESC: To resolve the spec 548 fluctuation problem, revert GCC commit.
* Fri Jun 9 2023 Wang Ding <wangding16@huawei.com> - 10.3.1-34
- Type:Sync
- ID:NA