Skip to content
Snippets Groups Projects
Commit 9bd1ee6d authored by Jan Hubicka's avatar Jan Hubicka
Browse files

Fix profile update in tree_transform_and_unroll_loop

Fixe profile update in tree_transform_and_unroll_loop which is used
by predictive comming.  I stared by attempt to fix
gcc.dg/tree-ssa/update-unroll-1.c I xfailed last week, but it turned to be
harder job.

Unrolling was never fixed for changes in duplicate_loop_body_to_header_edge
which is now smarter on getting profile right when some exists are eliminated.
A lot of manual profile can thus now be done using existing infrastructure.

I also noticed that scale_dominated_blocks_in_loop does job identical
to loop I wrote in scale_loop_profile and thus I commonized the implementaiton
and removed recursion.

I also extended duplicate_loop_body_to_header_edge to handle flat profiles same
way as we do in vectorizer. Without it we end up with less then 0 iteration
count in gcc.dg/tree-ssa/update-unroll-1.c (it is unrolled 32times but predicted
to iterated fewer times) and added missing code to update loop_info.

gcc/ChangeLog:

	* cfgloopmanip.cc (scale_dominated_blocks_in_loop): Move here from
	tree-ssa-loop-manip.cc and avoid recursion.
	(scale_loop_profile): Use scale_dominated_blocks_in_loop.
	(duplicate_loop_body_to_header_edge): Add DLTHE_FLAG_FLAT_PROFILE
	flag.
	* cfgloopmanip.h (DLTHE_FLAG_FLAT_PROFILE): Define.
	(scale_dominated_blocks_in_loop): Declare.
	* predict.cc (dump_prediction): Do not ICE on uninitialized probability.
	(change_edge_frequency): Remove.
	* predict.h (change_edge_frequency): Remove.
	* tree-ssa-loop-manip.cc (scale_dominated_blocks_in_loop): Move to
	cfgloopmanip.cc.
	(niter_for_unrolled_loop): Remove.
	(tree_transform_and_unroll_loop): Fix profile update.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr102385.c: Check for no profile mismatches.
	* gcc.dg/pr96931.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-1.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-2.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-3.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-4.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-5.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-7.c: Check for one profile mismatch.
	* gcc.dg/tree-ssa/predcom-8.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-1.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-10.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-11.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-12.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-2.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-3.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-4.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-5.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-6.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-7.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-8.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/predcom-dse-9.c: Check for no profile mismatches.
	* gcc.dg/tree-ssa/update-unroll-1.c: Unxfail.
parent 5b06b3b8
No related branches found
No related tags found
No related merge requests found
Showing
with 84 additions and 77 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment