From: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Guard against applying scale with 0 denominator
Date: Fri, 6 May 2022 20:31:00 +0000 [thread overview]
Message-ID: <MW2PR2101MB177075A47AD1E30F66CED4FE91C59@MW2PR2101MB1770.namprd21.prod.outlook.com> (raw)
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
next reply other threads:[~2022-05-06 20:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 20:31 Eugene Rozenfeld [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW2PR2101MB177075A47AD1E30F66CED4FE91C59@MW2PR2101MB1770.namprd21.prod.outlook.com \
--to=eugene.rozenfeld@microsoft.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).