public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] optimize x - y cmp 0 with undefined overflow
Date: Mon, 02 Jun 2014 10:37:00 -0000	[thread overview]
Message-ID: <CAFiYyc0bbMmrzVg3PgmENjaSTFzu4sjF=t4GfYq9yeCiZNYO6w@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc2YZOoquGM8E_+HtGBswQJS3yM9jBjaf4GKvaGNpwsfKg@mail.gmail.com>

On Mon, Jun 2, 2014 at 12:36 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Fri, May 30, 2014 at 10:48 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> I'd say we still handle "basic" symbolic range ops in
>>> extract_range_from_binary_1
>>> but in extract_range_from_binary_expr for a symbolic op0 we try to simplify
>>> it with both [op1, op1] and with the value-range of op1 until we get a
>>> non-varying range as result.  Not sure if it's worth restricting that
>>> to the case
>>> where op0s value-range refers to op1 or vice versa, and eventually only
>>> use op1 symbolically then.
>>
>> Patch along these lines attached.  A bit heavy as expected, but it's VRP...
>> It deals with my pet problem, you might want to check it does so with yours.
>>
>> Tested on x86_64-suse-linux with no regressions.
>
> Looks mostly ok.  Any reason why you are not re-creating
> MINUS_EXPR in build_symbolic_expr?  That is, build
> inv - t (for non-pointers, of course)?  Otherwise if a range
> becomes -t + inv that will no longer match get_single_symbol
> for further propagation?
>
> Then I'm not sure if
>
> +      /* Try with VR0 and [-INF, OP1].  */
> +      set_value_range (&new_vr1, VR_RANGE, vrp_val_min (expr_type), op1, NULL);
> +      extract_range_from_binary_expr_1 (vr, code, expr_type, &vr0, &new_vr1);
> +      if (vr->type != VR_VARYING)
> +       return;
> +
> +      /* Try with VR0 and [OP1, +INF].  */
> +      set_value_range (&new_vr1, VR_RANGE, op1, vrp_val_max (expr_type), NULL);
> +      extract_range_from_binary_expr_1 (vr, code, expr_type, &vr0, &new_vr1);
> +      if (vr->type != VR_VARYING)
> +       return;
>
> is a safe thing to do.  If it does make a difference to try [-INF, OP1],
> [OP1, +INF] instead of just [OP1, OP1] then at least it's very suspicious ;)
> (or an "easy" missed optimization).
>
> So - can you fix the negate thing and drop the four cases trying
> the +-INF based ranges?

Btw, the testcases are missing in the patch so I can't have a look myself.

Richard.

> Thanks,
> Richard.
>
>>
>> 2014-05-30  Eric Botcazou  <ebotcazou@adacore.com>
>>
>>         * tree-vrp.c (get_single_symbol): New function.
>>         (build_symbolic_expr): Likewise.
>>         (symbolic_range_based_on_p): New predicate.
>>         (extract_range_from_binary_expr_1): Deal with single-symbolic ranges
>>         for PLUS and MINUS.  Do not drop symbolic ranges at the end.
>>         (extract_range_from_binary_expr): Try harder for PLUS and MINUS if
>>         operand is symbolic and based on the other operand.
>>
>>
>> 2014-05-30  Eric Botcazou  <ebotcazou@adacore.com>
>>
>>         * gcc.dg/tree-ssa/vrp93.c: New test.
>>         * gnat.dg/opt38.adb: Likewise.
>>
>>
>> --
>> Eric Botcazou

  reply	other threads:[~2014-06-02 10:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 10:24 Eric Botcazou
2014-05-26 12:55 ` Richard Biener
2014-05-27  9:26   ` Eric Botcazou
2014-05-27  9:42     ` Richard Biener
2014-05-27 10:00       ` Eric Botcazou
2014-05-27 10:12         ` Richard Biener
2014-05-30  8:49           ` Eric Botcazou
2014-06-02 10:36             ` Richard Biener
2014-06-02 10:37               ` Richard Biener [this message]
2014-06-03  8:13               ` Eric Botcazou
2014-06-03 11:00                 ` Richard Biener
2014-06-06 10:54                   ` Eric Botcazou
2014-06-06 15:45                     ` Richard Biener
2014-06-20  9:40                       ` Eric Botcazou
2014-06-24 10:34                         ` Richard Biener
2014-09-29 23:01                           ` Eric Botcazou
2014-05-27 16:14       ` Eric Botcazou
2014-05-27 16:19         ` 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='CAFiYyc0bbMmrzVg3PgmENjaSTFzu4sjF=t4GfYq9yeCiZNYO6w@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=ebotcazou@adacore.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).