aboutsummaryrefslogtreecommitdiff
path: root/gcc/loop-unroll.cc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2023-07-27 20:06:37 +0200
committerJan Hubicka <jh@suse.cz>2023-07-27 20:08:38 +0200
commita7d4310aed539b04345894ebafb49ca364780653 (patch)
tree4eccf9cd5478617b3ebbc73373b75b071244297b /gcc/loop-unroll.cc
parent081e25d3cfd86c4094999ded0bbe99b91762013c (diff)
downloadgcc-a7d4310aed539b04345894ebafb49ca364780653.zip
gcc-a7d4310aed539b04345894ebafb49ca364780653.tar.gz
gcc-a7d4310aed539b04345894ebafb49ca364780653.tar.bz2
Fix profile update after RTL unrolling
This patch fixes profile update after RTL unroll, that is now done same way as in tree one. We still produce (slightly) corrupted profile for multiple exit loops I can try to fix incrementally. I also updated testcases to look for profile mismatches so they do not creep back in again. gcc/ChangeLog: * cfgloop.h (single_dom_exit): Declare. * cfgloopmanip.h (update_exit_probability_after_unrolling): Declare. * cfgrtl.cc (struct cfg_hooks): Fix comment. * loop-unroll.cc (unroll_loop_constant_iterations): Update exit edge. * tree-ssa-loop-ivopts.h (single_dom_exit): Do not declare it here. * tree-ssa-loop-manip.cc (update_exit_probability_after_unrolling): Break out from ... (tree_transform_and_unroll_loop): ... here; gcc/testsuite/ChangeLog: * gcc.dg/tree-prof/peel-1.c: Test for profile mismatches. * gcc.dg/tree-prof/unroll-1.c: Test for profile mismatches. * gcc.dg/tree-ssa/peel1.c: Test for profile mismatches. * gcc.dg/unroll-1.c: Test for profile mismatches. * gcc.dg/unroll-3.c: Test for profile mismatches. * gcc.dg/unroll-4.c: Test for profile mismatches. * gcc.dg/unroll-5.c: Test for profile mismatches. * gcc.dg/unroll-6.c: Test for profile mismatches.
Diffstat (limited to 'gcc/loop-unroll.cc')
-rw-r--r--gcc/loop-unroll.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/loop-unroll.cc b/gcc/loop-unroll.cc
index 93333d8..bbfa6cc 100644
--- a/gcc/loop-unroll.cc
+++ b/gcc/loop-unroll.cc
@@ -487,6 +487,7 @@ unroll_loop_constant_iterations (class loop *loop)
bool exit_at_end = loop_exit_at_end_p (loop);
struct opt_info *opt_info = NULL;
bool ok;
+ bool flat = maybe_flat_loop_profile (loop);
niter = desc->niter;
@@ -603,9 +604,14 @@ unroll_loop_constant_iterations (class loop *loop)
ok = duplicate_loop_body_to_header_edge (
loop, loop_latch_edge (loop), max_unroll, wont_exit, desc->out_edge,
&remove_edges,
- DLTHE_FLAG_UPDATE_FREQ | (opt_info ? DLTHE_RECORD_COPY_NUMBER : 0));
+ DLTHE_FLAG_UPDATE_FREQ | (opt_info ? DLTHE_RECORD_COPY_NUMBER : 0)
+ | (flat ? DLTHE_FLAG_FLAT_PROFILE : 0));
gcc_assert (ok);
+ edge new_exit = single_dom_exit (loop);
+ if (new_exit)
+ update_exit_probability_after_unrolling (loop, new_exit);
+
if (opt_info)
{
apply_opt_in_copies (opt_info, max_unroll, true, true);