Avoid division by zero in fold_loop_internal_call
Checks
Commit Message
Hi,
My patch to fix profile after folding internal call is missing check for the
case profile was already zero before if-conversion.
Bootstrapped/regtested x86_64-linux, comitted.
gcc/ChangeLog:
PR gcov-profile/110988
* tree-cfg.cc (fold_loop_internal_call): Avoid division by zero.
@@ -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);
+ }
}
}
}