From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "hernandez, aldy" <aldyh@redhat.com>
Subject: [PATCH] PR tree-optimization/107109 - Don't process undefined range.
Date: Mon, 3 Oct 2022 10:14:22 -0400 [thread overview]
Message-ID: <f39a8cab-7d04-ddc2-0e46-540325c6e84e@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 398 bytes --]
I audited all the op1/op2 range for undefined values, but missed that an
intervening calculation can also cause an undefined range in the middle
of operator_plus::op1_range, and that is the passed to
adjust_op1_for_overflow. That routine also needs to check for
undefined before asking for the type of the range.
Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
[-- Attachment #2: 107109 --]
[-- Type: text/plain, Size: 1359 bytes --]
commit f41d1b39a6443fad38c36af34b1baa384954ca80
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Sun Oct 2 18:43:35 2022 -0400
Don't process undefined range.
No need to continue processing an undefined range.
gcc/
PR tree-optimization/107109
* range-op.cc (adjust_op1_for_overflow): Don't process undefined.
gcc/testsuite/
* gcc.dg/pr107109.c: New.
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 7ef980315b6..4f647abd91c 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -1370,6 +1370,8 @@ static void
adjust_op1_for_overflow (irange &r, const irange &op2, relation_kind rel,
bool add_p)
{
+ if (r.undefined_p ())
+ return;
tree type = r.type ();
// Check for unsigned overflow and calculate the overflow part.
signop s = TYPE_SIGN (type);
diff --git a/gcc/testsuite/gcc.dg/pr107109.c b/gcc/testsuite/gcc.dg/pr107109.c
new file mode 100644
index 00000000000..e3036f6ff22
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr107109.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+int printf(const char *, ...);
+int a, b;
+void c() {
+ int d, e;
+ L:
+ a = (b && a) ^ 2756578370;
+ d = ~a + (e ^ d) ^ 2756578370;
+ if (!d)
+ printf("%d", a);
+ d = a / e;
+ goto L;
+}
+int main() {
+ if (a)
+ c();
+ return 0;
+}
+
reply other threads:[~2022-10-03 14:14 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=f39a8cab-7d04-ddc2-0e46-540325c6e84e@redhat.com \
--to=amacleod@redhat.com \
--cc=aldyh@redhat.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).