83 lines
3.4 KiB
Diff
83 lines
3.4 KiB
Diff
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
|
|
|