aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.h
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2023-07-12 17:22:03 +0200
committerJan Hubicka <jh@suse.cz>2023-07-12 17:22:03 +0200
commit14b10ff30ad58265c5acd495c3b0e56563571b0c (patch)
tree3939306bcc9c6d3d696ae54ef0e265a2f4aec8bb /gcc/tree-cfg.h
parent5a13caf2666bdf586272cc24a08ab90499771c95 (diff)
downloadgcc-14b10ff30ad58265c5acd495c3b0e56563571b0c.zip
gcc-14b10ff30ad58265c5acd495c3b0e56563571b0c.tar.gz
gcc-14b10ff30ad58265c5acd495c3b0e56563571b0c.tar.bz2
Improve profile update in loop-ch
Improve profile update in loop-ch to handle situation where duplicated header has loop invariant test. In this case we konw that all count of the exit edge belongs to the duplicated loop header edge and can update probabilities accordingly. Since we also do all the work to track this information from analysis to duplicaiton I also added code to turn those conditionals to constants so we do not need later jump threading pass to clean up. This made me to work out that the propagation was buggy in few aspects 1) it handled every PHI as PHI in header and incorrectly assigned some PHIs to be IV-like when they are not 2) it did not check for novops calls that are not required to return same value on every invocation. 3) I also added check for asm statement since those are not necessarily reproducible either. I would like to do more changes, but tried to prevent this patch from snowballing. The analysis of what statements will remain after duplication can be improved. I think we should use ranger query for other than first basic block, too and possibly drop the IV heuristics then. Also it seems that a lot of this logic is pretty much same to analysis in peeling pass, so unifying this would be nice. I also think I should move the profile update out of gimple_duplicate_sese_region (it is now very specific to ch) and rename it, since those regions are singe entry multiple exit. Bootstrapped/regtsted x86_64-linux, OK? Honza gcc/ChangeLog: * tree-cfg.cc (gimple_duplicate_sese_region): Add ORIG_ELIMINATED_EDGES parameter and rewrite profile updating code to handle edges elimination. * tree-cfg.h (gimple_duplicate_sese_region): Update prototpe. * tree-ssa-loop-ch.cc (loop_invariant_op_p): New function. (loop_iv_derived_p): New function. (should_duplicate_loop_header_p): Track invariant exit edges; fix handling of PHIs and propagation of IV derived variables. (ch_base::copy_headers): Pass around the invariant edges hash set. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/loop-ch-profile-1.c: Remove xfail.
Diffstat (limited to 'gcc/tree-cfg.h')
-rw-r--r--gcc/tree-cfg.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/tree-cfg.h b/gcc/tree-cfg.h
index b9ccd58..a7cc37f 100644
--- a/gcc/tree-cfg.h
+++ b/gcc/tree-cfg.h
@@ -70,7 +70,8 @@ extern void add_phi_args_after_copy_bb (basic_block);
extern void add_phi_args_after_copy (basic_block *, unsigned, edge);
extern basic_block split_edge_bb_loc (edge);
extern bool gimple_duplicate_sese_region (edge, edge, basic_block *, unsigned,
- basic_block *, bool, edge);
+ basic_block *, bool, edge,
+ hash_set <edge> *);
extern bool gimple_duplicate_sese_tail (edge, edge, basic_block *, unsigned,
basic_block *);
extern void gather_blocks_in_sese_region (basic_block entry, basic_block exit,