]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid division by zero in fold_loop_internal_call
authorJan Hubicka <jh@suse.cz>
Mon, 14 Aug 2023 15:55:33 +0000 (17:55 +0200)
committerJan Hubicka <jh@suse.cz>
Mon, 14 Aug 2023 15:55:33 +0000 (17:55 +0200)
My patch to fix profile after folding internal call is missing check for the
case profile was already zero before if-conversion.

gcc/ChangeLog:

PR gcov-profile/110988
* tree-cfg.cc (fold_loop_internal_call): Avoid division by zero.

gcc/tree-cfg.cc

index fae80bb5b91eaebb2f0c89f66b709f93876eb829..272d5ce321eb9b2e7d7fa6efd43931593dce1809 100644 (file)
@@ -7734,11 +7734,14 @@ fold_loop_internal_call (gimple *g, tree value)
                 test.  This should not happen as the guarded code should
                 start with pre-header.  */
              gcc_assert (single_pred_edge (taken_edge->dest));
-             taken_edge->dest->count
-               = taken_edge->dest->count.apply_scale (new_count,
-                                                      old_count);
-             scale_strictly_dominated_blocks (taken_edge->dest,
-                                              new_count, old_count);
+             if (old_count.nonzero_p ())
+               {
+                 taken_edge->dest->count
+                   = taken_edge->dest->count.apply_scale (new_count,
+                                                          old_count);
+                 scale_strictly_dominated_blocks (taken_edge->dest,
+                                                  new_count, old_count);
+               }
            }
        }
     }