]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: Set counts of early break exit blocks correctly [PR117790]
authorAlex Coplan <alex.coplan@arm.com>
Tue, 26 Nov 2024 17:48:14 +0000 (17:48 +0000)
committerAlex Coplan <alex.coplan@arm.com>
Wed, 12 Feb 2025 15:03:40 +0000 (15:03 +0000)
This adds missing code to correctly set the counts of the exit blocks we
create when building the CFG for a vectorized early break loop.

gcc/ChangeLog:

PR tree-optimization/117790
* tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
Set profile counts for {main,alt}_loop_exit_block.

gcc/tree-vect-loop-manip.cc

index 06ca99eaab95715e9ca15f9570a184bd635f3f1a..56a4e9a8b63f3cae0bf596bf5d22893887dc80e8 100644 (file)
@@ -1686,6 +1686,16 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop, edge loop_exit,
 
          set_immediate_dominator (CDI_DOMINATORS, new_preheader,
                                   loop->header);
+
+         /* Fix up the profile counts of the new exit blocks.
+            main_loop_exit_block was created by duplicating the
+            preheader, so needs its count scaling according to the main
+            exit edge's probability.  The remaining count from the
+            preheader goes to the alt_loop_exit_block, since all
+            alternative exits have been redirected there.  */
+         main_loop_exit_block->count = loop_exit->count ();
+         alt_loop_exit_block->count
+           = preheader->count - main_loop_exit_block->count;
        }
 
       /* Adjust the epilog loop PHI entry values to continue iteration.