]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/44794 - avoid excessive RTL unrolling on epilogues
authorRichard Biener <rguenther@suse.de>
Thu, 9 Mar 2023 08:02:07 +0000 (09:02 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 19 Apr 2023 11:50:21 +0000 (13:50 +0200)
The following adjusts tree_[transform_and_]unroll_loop to set an
upper bound on the number of iterations on the epilogue loop it
creates.  For the testcase at hand which involves array prefetching
this avoids applying RTL unrolling to them when -funroll-loops is
specified.

Other users of this API includes predictive commoning and
unroll-and-jam.

PR tree-optimization/44794
* tree-ssa-loop-manip.cc (tree_transform_and_unroll_loop):
If an epilogue loop is required set its iteration upper bound.

gcc/tree-ssa-loop-manip.cc

index 4ef27bae51527cf7475b459b41988c576ffcb348..a52277abdbf5a18b1371a131cae3b216dd87e75a 100644 (file)
@@ -1297,6 +1297,12 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor,
        }
 
       remove_path (exit);
+
+      /* The epilog loop latch executes at most factor - 1 times.
+        Since the epilog is entered unconditionally it will need to handle
+        up to factor executions of its body.  */
+      new_loop->any_upper_bound = 1;
+      new_loop->nb_iterations_upper_bound = factor - 1;
     }
   else
     new_exit = single_dom_exit (loop);