1 Star 0 Fork 118

caodongxia/gcc

forked from src-openEuler/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0032-Autoprefetch-Prune-invaild-loops-containing-edges-wh.patch 3.44 KB
一键复制 编辑 原始数据 按行查看 历史
From 071d19832d788422034a3b052ff7ce91e1010344 Mon Sep 17 00:00:00 2001
From: dingguangya <dingguangya1@huawei.com>
Date: Mon, 28 Feb 2022 16:52:58 +0800
Subject: [PATCH 32/32] [Autoprefetch] Prune invaild loops containing edges whose
probability exceeds 1
Skip auto prefetch analysis if the loop contains the bb in which the sum
of its outgoing edge probabilities is greater than 1.
---
gcc/testsuite/gcc.dg/autoprefetch/autoprefetch.exp | 2 +-
.../gcc.dg/autoprefetch/branch-weighted-prefetch.c | 8 ++++----
gcc/tree-ssa-loop-prefetch.c | 12 ++++++++++++
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/autoprefetch/autoprefetch.exp b/gcc/testsuite/gcc.dg/autoprefetch/autoprefetch.exp
index a7408e338..7cae630a2 100644
--- a/gcc/testsuite/gcc.dg/autoprefetch/autoprefetch.exp
+++ b/gcc/testsuite/gcc.dg/autoprefetch/autoprefetch.exp
@@ -20,7 +20,7 @@ load_lib target-supports.exp
# Initialize `dg'.
dg-init
-gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] \
"" "-fprefetch-loop-arrays"
# All done.
diff --git a/gcc/testsuite/gcc.dg/autoprefetch/branch-weighted-prefetch.c b/gcc/testsuite/gcc.dg/autoprefetch/branch-weighted-prefetch.c
index c63c5e5cb..ab537cb29 100644
--- a/gcc/testsuite/gcc.dg/autoprefetch/branch-weighted-prefetch.c
+++ b/gcc/testsuite/gcc.dg/autoprefetch/branch-weighted-prefetch.c
@@ -1,5 +1,5 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -fprefetch-loop-arrays=2 --param min-insn-to-prefetch-ratio=5 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
+/* { dg-do compile { target { aarch64*-*-linux* } } } */
+/* { dg-options "-O2 -fprefetch-loop-arrays=2 --param min-insn-to-prefetch-ratio=5 --param simultaneous-prefetches=100 --param l1-cache-size=64 --param l1-cache-line-size=32 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
#define N 10000000
long long a[N];
@@ -18,5 +18,5 @@ long long func ()
return sum;
}
-/* { dg-final { scan-tree-dump-times "Ahead 40" 1 "aprefetch" } } */
-/* { dg-final { scan-tree-dump-times "builtin_prefetch" 1 "optimized" } } */
\ No newline at end of file
+/* { dg-final { scan-tree-dump "Calculating prefetch distance using bb branch weighting method" "aprefetch" } } */
+/* { dg-final { scan-tree-dump "builtin_prefetch" "optimized" } } */
\ No newline at end of file
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 673f453a4..0d992d8f6 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -2267,6 +2267,15 @@ traverse_prune_bb_branch (hash_map <basic_block, bb_bp> &bb_branch_prob,
&& bb_bp_node->false_edge_bb == NULL))
return false;
+ /* Do not process the loop with a bb branch probability of an abnormal
+ value. */
+ if (bb_bp_node->true_edge_prob + bb_bp_node->false_edge_prob > 1)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "bb branch probability is abnormal\n");
+ return false;
+ }
+
if (current_bb == latch_bb)
{
max_path--;
@@ -2409,6 +2418,9 @@ estimate_num_loop_insns (struct loop *loop, eni_weights *weights)
dump_loop_bb (loop);
return 0;
}
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Calculating prefetch distance using bb branch "
+ "weighting method\n");
}
for (unsigned i = 0; i < loop->num_nodes; i++)
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/caodongxia/gcc.git
git@gitee.com:caodongxia/gcc.git
caodongxia
gcc
gcc
master

搜索帮助