This patchset is a recollect of previously sent patches. Thanks Richard that The "Don't move cold code out of loop by checking bb count" is approved[1], but there are still 3 prerequesite patches to supplement or avoid regression.
1) Patch [1/3] is the RTL part of not hoisting LIM code out of cold loop, it could improve perlbench by 7.69% [2]. 2) Patch [2/3] is a test case regression fix for pr103270.c, after enabling gimple part of hoisting LIM code to coldest loop [1], the store instruction in loop won't be moved out of inner loop, it is caused by a jump-threading patch unexpectedly turning a hot inner loop to cold loop, this patch could recover the inner loop to be hot[3]. 3) As data showed in [2], besides improvement, there is also a small regression on SPEC2017 544.nab_r (-1.55%). After investigation, it turned out to be the profile count and probability is not correctly adjusted in loop split, with this patch [3/3], the only regression is also fixed. This version slightly updates [4] to fix ICEs. [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586319.html [2] https://gcc.gnu.org/pipermail/gcc-patches/2021-September/580109.html [3] https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585195.html [4] https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585290.html Xionghu Luo (3): loop-invariant: Don't move cold bb instructions to preheader in RTL Fix incorrect loop exit edge probability [PR103270] Fix loop split incorrect count and probability gcc/loop-invariant.c | 10 ++-- gcc/predict.c | 10 ++-- gcc/tree-ssa-loop-split.c | 85 +++++++++++++++++++++++++++++---- gcc/testsuite/gcc.dg/pr103270.c | 19 ++++++++ 4 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr103270.c -- 2.25.1