Fix ICE in lsplit when built with -O3 -fno-guess-branch-probability [PR103793]
authorXionghu Luo <luoxhu@linux.ibm.com>
Wed, 29 Dec 2021 01:09:14 +0000 (19:09 -0600)
committerXionghu Luo <luoxhu@linux.ibm.com>
Wed, 29 Dec 2021 01:11:28 +0000 (19:11 -0600)
commit44372676e81358de29d5c853685a7664a95d8a96
tree0a4e76fdcad408ddebe415e5886fa65c5c7b1104
parent054e57e467b15677966f832b491b1584feb194ee
Fix ICE in lsplit when built with -O3 -fno-guess-branch-probability [PR103793]

no-guess-branch-probability option requires profile_count scaling with
initialized_p guard, use multiply instead of apply_scale, which will do
the right thing to undefined probabilities and will not cause unnecesary
roundoff errors and precision info loss.
Also merge the missed part of r12-6086 of factor out function to avoid
duplicate code.

Regression testest pass on Power and X86.

gcc/ChangeLog:

PR tree-optimization/103793
* tree-ssa-loop-split.c (fix_loop_bb_probability): New function.
(split_loop): Use multiply to scale loop1's exit probability.
(do_split_loop_on_cond): Call fix_loop_bb_probability.

gcc/testsuite/ChangeLog:

PR tree-optimization/103793
* gcc.dg/pr103793.c: New test.
gcc/testsuite/gcc.dg/pr103793.c [new file with mode: 0644]
gcc/tree-ssa-loop-split.c