Calling count.apply_scale with a 0 denominator causes an assert. This change guards against that.
Tested on x86_64-pc-linux-gnu. gcc/ChangeLog: * tree-loop-vect-manip.cc (vect_do_peeling): Guard against applying scale with 0 denominator. --- gcc/tree-vect-loop-manip.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index 1d4337eb261..db54ae69e45 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -2989,10 +2989,11 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, get lost if we scale down to 0. */ basic_block *bbs = get_loop_body (epilog); for (unsigned int i = 0; i < epilog->num_nodes; i++) - bbs[i]->count = bbs[i]->count.apply_scale - (bbs[i]->count, - bbs[i]->count.apply_probability - (prob_vector)); + if (bbs[i]->count.nonzero_p ()) + bbs[i]->count = bbs[i]->count.apply_scale + (bbs[i]->count, + bbs[i]->count.apply_probability + (prob_vector)); free (bbs); } -- 2.25.1