public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Marc Glisse <marc.glisse@inria.fr>, gcc-patches@gcc.gnu.org
Subject: Re: VRP: x+1 and -x cannot be INT_MIN
Date: Sun, 12 Nov 2017 21:16:00 -0000	[thread overview]
Message-ID: <a2052301-d154-0597-d977-cd9bfe61d9f0@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1711112244260.7206@stedding.saclay.inria.fr>

On 11/11/2017 03:03 PM, Marc Glisse wrote:
> Hello,
>
> with undefined overflow, just because we know nothing about one of the
> arguments of an addition doesn't mean we can't say something about the
> result. We could constrain more the cases where we replace VR_VARYING
> with a full VR_RANGE, but I didn't want to duplicate too much logic.
>
> The 20040409 testcases were introduced to test an RTL transformation, so
> I don't feel too bad adding -fwrapv to work around the undefined
> overflows they exhibit.
>
> Bootstrap+regtest on powerpc64le-unknown-linux-gnu.
>
> 2017-11-13  Marc Glisse  <marc.glisse@inria.fr>
>
> gcc/
>     * tree-vrp.c (extract_range_from_binary_expr_1) [PLUS_EXPR,
>     MINUS_EXPR]: Use a full range for VR_VARYING.
>
> gcc/testsuite/
>     PR testsuite/82951
>     * gcc.c-torture/execute/20040409-1.c: Use -fwrapv.
>     * gcc.c-torture/execute/20040409-2.c: Likewise.
>     * gcc.c-torture/execute/20040409-3.c: Likewise.
>     * gcc.dg/tree-ssa/vrp118.c: New file.
>

I'm curious about the 4 in the added test case (copied below).
Is there some significance to it or is actually meant to be
(or could it be) a 2?

FWIW, if there's some significance to the 4 then it would be
nice to have a comment there explaining it.  If there isn't
any then may I suggest to either change it to 2 or, perhaps
even better, change the second if condition to
(x < -__INT_MAX__ + 3) to make the effect on the range of
x clear and (presumably) also obviate questions like this
one.

Martin

+++ gcc/testsuite/gcc.dg/tree-ssa/vrp118.c	(working copy)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+void eliminate_me();
+void f(int x,int y){
+    if (y < 4)
+      __builtin_unreachable();
+    x += y;
+    if (x == -__INT_MAX__)
+      eliminate_me ();
+}
+
+/* { dg-final { scan-tree-dump-not "eliminate_me" "optimized" } } */

  parent reply	other threads:[~2017-11-12 18:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-11 22:16 Marc Glisse
2017-11-11 22:17 ` Jakub Jelinek
2017-11-12  0:39   ` Marc Glisse
2017-11-12 21:16 ` Martin Sebor [this message]
2017-11-12 21:17   ` Marc Glisse
2017-11-13 13:40 ` Richard Biener
2017-11-19 11:02   ` Marc Glisse
2017-11-19 21:51     ` Jeff Law
2017-11-20 10:41     ` Richard Biener
2017-11-20 14:16       ` Marc Glisse
2017-11-20 15:09         ` 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=a2052301-d154-0597-d977-cd9bfe61d9f0@gmail.com \
    --to=msebor@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=marc.glisse@inria.fr \
    /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).