aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-prefetch.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-07-27 10:15:41 -0700
committerIan Lance Taylor <iant@golang.org>2022-07-27 10:15:41 -0700
commit9f62ed218fa656607740b386c0caa03e65dcd283 (patch)
tree6bde49bc5e4c4241266b108e4277baef4b85535d /gcc/tree-ssa-loop-prefetch.cc
parent71e955da39cea0ebffcfee3432effa622d14ca99 (diff)
parent5eb9f117a361538834b9740d59219911680717d1 (diff)
downloadgcc-9f62ed218fa656607740b386c0caa03e65dcd283.zip
gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.gz
gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.bz2
Merge from trunk revision 5eb9f117a361538834b9740d59219911680717d1.
Diffstat (limited to 'gcc/tree-ssa-loop-prefetch.cc')
-rw-r--r--gcc/tree-ssa-loop-prefetch.cc34
1 files changed, 22 insertions, 12 deletions
diff --git a/gcc/tree-ssa-loop-prefetch.cc b/gcc/tree-ssa-loop-prefetch.cc
index aebd7c9..b6690b0 100644
--- a/gcc/tree-ssa-loop-prefetch.cc
+++ b/gcc/tree-ssa-loop-prefetch.cc
@@ -1308,8 +1308,6 @@ emit_mfence_after_loop (class loop *loop)
gsi_insert_before (&bsi, call, GSI_NEW_STMT);
}
-
- update_ssa (TODO_update_ssa_only_virtuals);
}
/* Returns true if we can use storent in loop, false otherwise. */
@@ -1340,23 +1338,27 @@ may_use_storent_in_loop_p (class loop *loop)
}
/* Marks nontemporal stores in LOOP. GROUPS contains the description of memory
- references in the loop. */
+ references in the loop. Returns whether we inserted any mfence call. */
-static void
+static bool
mark_nontemporal_stores (class loop *loop, struct mem_ref_group *groups)
{
struct mem_ref *ref;
bool any = false;
if (!may_use_storent_in_loop_p (loop))
- return;
+ return false;
for (; groups; groups = groups->next)
for (ref = groups->refs; ref; ref = ref->next)
any |= mark_nontemporal_store (ref);
if (any && FENCE_FOLLOWING_MOVNT != NULL_TREE)
- emit_mfence_after_loop (loop);
+ {
+ emit_mfence_after_loop (loop);
+ return true;
+ }
+ return false;
}
/* Determines whether we can profitably unroll LOOP FACTOR times, and if
@@ -1874,10 +1876,11 @@ insn_to_prefetch_ratio_too_small_p (unsigned ninsns, unsigned prefetch_count,
/* Issue prefetch instructions for array references in LOOP. Returns
- true if the LOOP was unrolled. */
+ true if the LOOP was unrolled and updates NEED_LC_SSA_UPDATE if we need
+ to update SSA for virtual operands and LC SSA for a split edge. */
static bool
-loop_prefetch_arrays (class loop *loop)
+loop_prefetch_arrays (class loop *loop, bool &need_lc_ssa_update)
{
struct mem_ref_group *refs;
unsigned ahead, ninsns, time, unroll_factor;
@@ -1952,7 +1955,7 @@ loop_prefetch_arrays (class loop *loop)
unroll_factor))
goto fail;
- mark_nontemporal_stores (loop, refs);
+ need_lc_ssa_update |= mark_nontemporal_stores (loop, refs);
/* Step 4: what to prefetch? */
if (!schedule_prefetches (refs, unroll_factor, ahead))
@@ -1980,6 +1983,7 @@ unsigned int
tree_ssa_prefetch_arrays (void)
{
bool unrolled = false;
+ bool need_lc_ssa_update = false;
int todo_flags = 0;
if (!targetm.have_prefetch ()
@@ -2028,12 +2032,15 @@ tree_ssa_prefetch_arrays (void)
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Processing loop %d:\n", loop->num);
- unrolled |= loop_prefetch_arrays (loop);
+ unrolled |= loop_prefetch_arrays (loop, need_lc_ssa_update);
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\n\n");
}
+ if (need_lc_ssa_update)
+ rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_only_virtuals);
+
if (unrolled)
{
scev_reset ();
@@ -2069,8 +2076,11 @@ public:
{}
/* opt_pass methods: */
- virtual bool gate (function *) { return flag_prefetch_loop_arrays > 0; }
- virtual unsigned int execute (function *);
+ bool gate (function *) final override
+ {
+ return flag_prefetch_loop_arrays > 0;
+ }
+ unsigned int execute (function *) final override;
}; // class pass_loop_prefetch