public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6653] tree-vect-patterns: Fix up ICE in upper_bound [PR109115] Date: Tue, 14 Mar 2023 08:16:23 +0000 (GMT) [thread overview] Message-ID: <20230314081623.CE5C23858D32@sourceware.org> (raw) https://gcc.gnu.org/g:72b52751c60abb327c73716259485d04b8eabe4f commit r13-6653-g72b52751c60abb327c73716259485d04b8eabe4f Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Mar 14 09:15:38 2023 +0100 tree-vect-patterns: Fix up ICE in upper_bound [PR109115] As mentioned in the PR, range_of_expr returns false if the type of the expression isn't suitable for corresponding range type, but doesn't if the range is undefined for other reasons. Still, lower/upper_bound is defined only for ranges which actually have at least one pair of subranges, VR_UNDEFINED range doesn't have it. 2023-03-14 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/109115 * tree-vect-patterns.cc (vect_recog_divmod_pattern): Don't use r.upper_bound () on r.undefined_p () range. * gcc.dg/pr109115.c: New test. Diff: --- gcc/testsuite/gcc.dg/pr109115.c | 20 ++++++++++++++++++++ gcc/tree-vect-patterns.cc | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr109115.c b/gcc/testsuite/gcc.dg/pr109115.c new file mode 100644 index 00000000000..780477105ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr109115.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/109115 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, b; + +int +main () +{ + unsigned short c = a, e = -1; + if (b) + { + unsigned d = (a ^ 1U) / a & c; + int f = (~d >> ~a) / e; + if (a) + f = a; + a = f; + } + return 0; +} diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 887f02bf336..8802141cd6e 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -3973,7 +3973,7 @@ vect_recog_divmod_pattern (vec_info *vinfo, /* Check that no overflow will occur. If we don't have range information we can't perform the optimization. */ - if (ranger.range_of_expr (r, oprnd0, stmt)) + if (ranger.range_of_expr (r, oprnd0, stmt) && !r.undefined_p ()) { wide_int max = r.upper_bound (); wide_int one = wi::shwi (1, prec);
reply other threads:[~2023-03-14 8:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230314081623.CE5C23858D32@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).