public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Guard against applying scale with 0 denominator
@ 2022-05-06 20:31 Eugene Rozenfeld
  2022-05-09  7:42 ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Eugene Rozenfeld @ 2022-05-06 20:31 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-23 10:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06 20:31 [PATCH] Guard against applying scale with 0 denominator Eugene Rozenfeld
2022-05-09  7:42 ` Richard Biener
2022-05-12  1:37   ` [EXTERNAL] " Eugene Rozenfeld
2022-05-12  7:34     ` Richard Biener
2022-05-20 22:28       ` Eugene Rozenfeld
2022-05-23 10:33         ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).