[Sync] Add attribute hot judgement for INLINE_HINT_known_hot hint.
We set up INLINE_HINT_known_hot hint only when we have profile feedback, now add function attribute judgement for it, when both caller and callee have __attribute__((hot)), we will also set up INLINE_HINT_known_hot hint for it. With this patch applied, ADL Multi-copy: 538.imagic_r 16.7% ICX Multi-copy: 538.imagic_r 15.2% CLX Multi-copy: 538.imagic_r 12.7% Znver3 Multi-copy: 538.imagic_r 10.6% Arm Multi-copy: 538.imagic_r 13.4% gcc/ChangeLog * ipa-inline-analysis.cc (do_estimate_edge_time): Add function attribute judgement for INLINE_HINT_known_hot hint. gcc/testsuite/ChangeLog: * gcc.dg/ipa/inlinehint-6.c: New test.
This commit is contained in:
parent
110ceef4aa
commit
8cf4a6a8c3
124
0003-Add-attribute-hot-judgement-for-INLINE_HINT_known_ho.patch
Normal file
124
0003-Add-attribute-hot-judgement-for-INLINE_HINT_known_ho.patch
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
From 355eb8e20327242442d139fb052d3a3befde3dd7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Cui,Lili" <lili.cui@intel.com>
|
||||||
|
Date: Tue, 1 Nov 2022 09:16:49 +0800
|
||||||
|
Subject: [PATCH] Add attribute hot judgement for INLINE_HINT_known_hot
|
||||||
|
hint.
|
||||||
|
|
||||||
|
We set up INLINE_HINT_known_hot hint only when we have profile feedback,
|
||||||
|
now add function attribute judgement for it, when both caller and callee
|
||||||
|
have __attribute__((hot)), we will also set up INLINE_HINT_known_hot hint
|
||||||
|
for it.
|
||||||
|
|
||||||
|
With this patch applied,
|
||||||
|
ADL Multi-copy: 538.imagic_r 16.7%
|
||||||
|
ICX Multi-copy: 538.imagic_r 15.2%
|
||||||
|
CLX Multi-copy: 538.imagic_r 12.7%
|
||||||
|
Znver3 Multi-copy: 538.imagic_r 10.6%
|
||||||
|
Arm Multi-copy: 538.imagic_r 13.4%
|
||||||
|
|
||||||
|
gcc/ChangeLog
|
||||||
|
|
||||||
|
* ipa-inline-analysis.cc (do_estimate_edge_time): Add function attribute
|
||||||
|
judgement for INLINE_HINT_known_hot hint.
|
||||||
|
|
||||||
|
gcc/testsuite/ChangeLog:
|
||||||
|
|
||||||
|
* gcc.dg/ipa/inlinehint-6.c: New test.
|
||||||
|
---
|
||||||
|
gcc/ipa-inline-analysis.cc | 13 ++++---
|
||||||
|
gcc/testsuite/gcc.dg/ipa/inlinehint-6.c | 47 +++++++++++++++++++++++++
|
||||||
|
2 files changed, 56 insertions(+), 4 deletions(-)
|
||||||
|
create mode 100644 gcc/testsuite/gcc.dg/ipa/inlinehint-6.c
|
||||||
|
|
||||||
|
diff --git a/gcc/ipa-inline-analysis.cc b/gcc/ipa-inline-analysis.cc
|
||||||
|
index 11d8d09ee..16ac24cfc 100644
|
||||||
|
--- a/gcc/ipa-inline-analysis.cc
|
||||||
|
+++ b/gcc/ipa-inline-analysis.cc
|
||||||
|
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see
|
||||||
|
#include "ipa-utils.h"
|
||||||
|
#include "cfgexpand.h"
|
||||||
|
#include "gimplify.h"
|
||||||
|
+#include "attribs.h"
|
||||||
|
|
||||||
|
/* Cached node/edge growths. */
|
||||||
|
fast_call_summary<edge_growth_cache_entry *, va_heap> *edge_growth_cache = NULL;
|
||||||
|
@@ -249,15 +250,19 @@ do_estimate_edge_time (struct cgraph_edge *edge, sreal *ret_nonspec_time)
|
||||||
|
hints = estimates.hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
- /* When we have profile feedback, we can quite safely identify hot
|
||||||
|
- edges and for those we disable size limits. Don't do that when
|
||||||
|
- probability that caller will call the callee is low however, since it
|
||||||
|
+ /* When we have profile feedback or function attribute, we can quite safely
|
||||||
|
+ identify hot edges and for those we disable size limits. Don't do that
|
||||||
|
+ when probability that caller will call the callee is low however, since it
|
||||||
|
may hurt optimization of the caller's hot path. */
|
||||||
|
- if (edge->count.ipa ().initialized_p () && edge->maybe_hot_p ()
|
||||||
|
+ if ((edge->count.ipa ().initialized_p () && edge->maybe_hot_p ()
|
||||||
|
&& (edge->count.ipa ().apply_scale (2, 1)
|
||||||
|
> (edge->caller->inlined_to
|
||||||
|
? edge->caller->inlined_to->count.ipa ()
|
||||||
|
: edge->caller->count.ipa ())))
|
||||||
|
+ || (lookup_attribute ("hot", DECL_ATTRIBUTES (edge->caller->decl))
|
||||||
|
+ != NULL
|
||||||
|
+ && lookup_attribute ("hot", DECL_ATTRIBUTES (edge->callee->decl))
|
||||||
|
+ != NULL))
|
||||||
|
hints |= INLINE_HINT_known_hot;
|
||||||
|
|
||||||
|
gcc_checking_assert (size >= 0);
|
||||||
|
diff --git a/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c b/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000..1f3be641c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c
|
||||||
|
@@ -0,0 +1,47 @@
|
||||||
|
+/* { dg-options "-O3 -c -fdump-ipa-inline-details -fno-early-inlining -fno-ipa-cp" } */
|
||||||
|
+/* { dg-add-options bind_pic_locally } */
|
||||||
|
+
|
||||||
|
+#define size_t long long int
|
||||||
|
+
|
||||||
|
+struct A
|
||||||
|
+{
|
||||||
|
+ size_t f1, f2, f3, f4;
|
||||||
|
+};
|
||||||
|
+struct C
|
||||||
|
+{
|
||||||
|
+ struct A a;
|
||||||
|
+ size_t b;
|
||||||
|
+};
|
||||||
|
+struct C x;
|
||||||
|
+
|
||||||
|
+__attribute__((hot)) struct C callee (struct A *a, struct C *c)
|
||||||
|
+{
|
||||||
|
+ c->a=(*a);
|
||||||
|
+
|
||||||
|
+ if((c->b + 7) & 17)
|
||||||
|
+ {
|
||||||
|
+ c->a.f1 = c->a.f2 + c->a.f1;
|
||||||
|
+ c->a.f2 = c->a.f3 - c->a.f2;
|
||||||
|
+ c->a.f3 = c->a.f2 + c->a.f3;
|
||||||
|
+ c->a.f4 = c->a.f2 - c->a.f4;
|
||||||
|
+ c->b = c->a.f2;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ return *c;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+__attribute__((hot)) struct C caller (size_t d, size_t e, size_t f, size_t g, struct C *c)
|
||||||
|
+{
|
||||||
|
+ struct A a;
|
||||||
|
+ a.f1 = 1 + d;
|
||||||
|
+ a.f2 = e;
|
||||||
|
+ a.f3 = 12 + f;
|
||||||
|
+ a.f4 = 68 + g;
|
||||||
|
+ if (c->b > 0)
|
||||||
|
+ return callee (&a, c);
|
||||||
|
+ else
|
||||||
|
+ return *c;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* { dg-final { scan-ipa-dump "known_hot" "inline" } } */
|
||||||
|
+
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
||||||
8
gcc.spec
8
gcc.spec
@ -2,7 +2,7 @@
|
|||||||
%global gcc_major 12
|
%global gcc_major 12
|
||||||
# Note, gcc_release must be integer, if you want to add suffixes to
|
# Note, gcc_release must be integer, if you want to add suffixes to
|
||||||
# %%{release}, append them after %%{gcc_release} on Release: line.
|
# %%{release}, append them after %%{gcc_release} on Release: line.
|
||||||
%global gcc_release 4
|
%global gcc_release 5
|
||||||
|
|
||||||
%global _unpackaged_files_terminate_build 0
|
%global _unpackaged_files_terminate_build 0
|
||||||
%global _performance_build 1
|
%global _performance_build 1
|
||||||
@ -139,6 +139,7 @@ Provides: gcc(major) = %{gcc_major}
|
|||||||
Patch0: 0000-Version-Set-version-to-12.3.1.patch
|
Patch0: 0000-Version-Set-version-to-12.3.1.patch
|
||||||
Patch1: 0001-CONFIG-Regenerate-configure-file.patch
|
Patch1: 0001-CONFIG-Regenerate-configure-file.patch
|
||||||
Patch2: 0002-libquadmath-Enable-libquadmath-on-kunpeng.patch
|
Patch2: 0002-libquadmath-Enable-libquadmath-on-kunpeng.patch
|
||||||
|
Patch3: 0003-Add-attribute-hot-judgement-for-INLINE_HINT_known_ho.patch
|
||||||
|
|
||||||
# On ARM EABI systems, we do want -gnueabi to be part of the
|
# On ARM EABI systems, we do want -gnueabi to be part of the
|
||||||
# target triple.
|
# target triple.
|
||||||
@ -609,6 +610,7 @@ not stable, so plugins must be rebuilt any time GCC is updated.
|
|||||||
%patch0 -p1
|
%patch0 -p1
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
|
||||||
echo '%{_vendor} %{version}-%{release}' > gcc/DEV-PHASE
|
echo '%{_vendor} %{version}-%{release}' > gcc/DEV-PHASE
|
||||||
|
|
||||||
@ -2712,6 +2714,10 @@ end
|
|||||||
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Aug 11 2023 Cui,Lili <lili.cui@intel.com> 12.3.1-5
|
||||||
|
- Type:Sync
|
||||||
|
- Add attribute hot judgement for INLINE_HINT_known_hot hint.
|
||||||
|
|
||||||
* Mon Jul 17 2023 huangxiaoquan <huangxiaoquan1@huawei.com> 12.3.1-4
|
* Mon Jul 17 2023 huangxiaoquan <huangxiaoquan1@huawei.com> 12.3.1-4
|
||||||
- Type:SPEC
|
- Type:SPEC
|
||||||
- DESC:Enable libquadmath on kunpeng
|
- DESC:Enable libquadmath on kunpeng
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user