]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix profile update after cancelled loop distribution
authorJan Hubicka <jh@suse.cz>
Wed, 2 Aug 2023 07:25:12 +0000 (09:25 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 2 Aug 2023 07:25:12 +0000 (09:25 +0200)
commit2e93b92c1ec5fbbbe10765c6e059c3c90d564245
tree2558f4a90e7cc2573f35a274dc5628097a964479
parent07b7cd70399d22c113ad8bb1eff5cc2d12973d33
Fix profile update after cancelled loop distribution

Loop distribution and ifcvt introduces verisons of loops which may be removed
later if vectorization fails.  Ifcvt does this by temporarily breaking profile
and producing conditional that has two arms with 100% probability because we
know one of the versions will be removed.

Loop distribution is trickier, since it introduces test for alignment that
either survives to final code if vecotorization suceeds or is turned if it
fails.

Here we need to assign some reasonable probabilities for the case vectorization
goes well, so this code adds logic to scale profile back in case we remove the
call.

This is not perfect since we drop precise BB counts to guessed.  It is not big
deal since we do not use much reliablity of bb counts after this point.  Other
option would be to apply scale only if vectorization succeeds which however
needs bit more work at tree-loop-distribution side and would need all code in
this patch with small change that fold_loop_internal_call will have to know how
to adjust if conditional stays. I decided to go for easier solution for now.

Bootstrapped/regtested x86_64-linux, committed.

gcc/ChangeLog:

* cfg.cc (scale_strictly_dominated_blocks): New function.
* cfg.h (scale_strictly_dominated_blocks): Declare.
* tree-cfg.cc (fold_loop_internal_call): Fixup CFG profile.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/pr98308.c: Check that profile is consistent.
gcc/cfg.cc
gcc/cfg.h
gcc/testsuite/gcc.dg/vect/pr98308.c
gcc/tree-cfg.cc