From: Jan Hubicka Date: Sun, 6 Aug 2023 20:33:33 +0000 (+0200) Subject: Disable loop distribution for loops with estimated iterations 0 X-Git-Tag: basepoints/gcc-15~7129 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3e6db43640fadc9aa41c5459d43e5541d83f29a;p=thirdparty%2Fgcc.git Disable loop distribution for loops with estimated iterations 0 This prevents useless loop distribiton produced in hmmer. With FDO we now correctly work out that the loop created for last iteraiton is not going to iterate however loop distribution still produces a verioned loop that has no chance to survive loop vectorizer since we only keep distributed loops when loop vectorization suceeds and it requires number of (header) iterations to exceed the vectorization factor. gcc/ChangeLog: * tree-loop-distribution.cc (loop_distribution::execute): Disable distribution for loops with estimated iterations 0. --- diff --git a/gcc/tree-loop-distribution.cc b/gcc/tree-loop-distribution.cc index cf7c197aaf79..a28470b66ea9 100644 --- a/gcc/tree-loop-distribution.cc +++ b/gcc/tree-loop-distribution.cc @@ -120,6 +120,7 @@ along with GCC; see the file COPYING3. If not see #include "rtl.h" #include "memmodel.h" #include "optabs.h" +#include "tree-ssa-loop-niter.h" #define MAX_DATAREFS_NUM \ @@ -3871,10 +3872,20 @@ loop_distribution::execute (function *fun) bool destroy_p; int nb_generated_loops, nb_generated_calls; + bool only_patterns = !optimize_loop_for_speed_p (loop) + || !flag_tree_loop_distribution; + /* do not try to distribute loops that are not expected to iterate. */ + if (!only_patterns) + { + HOST_WIDE_INT iterations = estimated_loop_iterations_int (loop); + if (iterations < 0) + iterations = likely_max_loop_iterations_int (loop); + if (!iterations) + only_patterns = true; + } nb_generated_loops = distribute_loop (loop, work_list, cd, &nb_generated_calls, - &destroy_p, (!optimize_loop_for_speed_p (loop) - || !flag_tree_loop_distribution)); + &destroy_p, only_patterns); if (destroy_p) loops_to_be_destroyed.safe_push (loop);