]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/cfg.cc
Fix profile update after cancelled loop distribution
[thirdparty/gcc.git] / gcc / cfg.cc
index 0de6d6b9e71d030227fce6ace2e8984219ee3dad..9eb9916f61aab63bbbeefe9a2e7134717fac8aec 100644 (file)
@@ -1195,3 +1195,27 @@ get_loop_copy (class loop *loop)
   else
     return NULL;
 }
+
+/* Scales the frequencies of all basic blocks that are strictly
+   dominated by BB by NUM/DEN.  */
+
+void
+scale_strictly_dominated_blocks (basic_block bb,
+                                profile_count num, profile_count den)
+{
+  basic_block son;
+
+  if (!den.nonzero_p () && !(num == profile_count::zero ()))
+    return;
+  auto_vec <basic_block, 8> worklist;
+  worklist.safe_push (bb);
+
+  while (!worklist.is_empty ())
+    for (son = first_dom_son (CDI_DOMINATORS, worklist.pop ());
+        son;
+        son = next_dom_son (CDI_DOMINATORS, son))
+      {
+       son->count = son->count.apply_scale (num, den);
+       worklist.safe_push (son);
+      }
+}