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: [patch] Fix segfault caused by spurious constant overflow
Date: Tue, 04 Jun 2019 15:06:00 -0000	[thread overview]
Message-ID: <CAFiYyc21XMZ9vDWhjkVyTw+yYFFzVKt8rJ=gHkC4BgZ5CmS7Pw@mail.gmail.com> (raw)
In-Reply-To: <11556037.CDzcRUGLMd@polaris>

On Mon, Jun 3, 2019 at 12:38 PM Eric Botcazou <ebotcazou@adacore.com> wrote:
>
> > Hmm, ISTR we had such mitigations in place (or have) elsewhere keying
> > on the most significant bit set instead of power-of-two.  But your case
> > likely recurses and runs into the extract_multiv limiting to eventually
> > stop, even for (N + 4) * 8, right?  If so shouldn't we prevent this
> > even for !TYPE_OVERFLOW_WRAPS?  Also
> >
> > +         && !(tree_fits_shwi_p (c)
> > +              && exact_log2 (absu_hwi (tree_to_shwi (c))) > 0))
> >
> > is better written as
> >
> >            && exact_log2 (wi::to_wide (c)) > 0
>
> It turns out that pow2p_hwi can be used instead and is cheaper, so I have
> changed both extract_muldiv_1 and fold_plusminus_mult_expr to using it.

OK, thanks.
Richard.

>
>         * fold-const.c (extract_muldiv_1) <PLUS_EXPR>: Do not distribute a
>         multiplication by a power-of-two value.
>         (fold_plusminus_mult_expr): Use pow2p_hwi to detect a power-of-two value
>         and turn the modulo operation into a masking operation.
>
> --
> Eric Botcazou

      reply	other threads:[~2019-06-04 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 10:31 Eric Botcazou
2019-05-31 11:44 ` Richard Biener
2019-05-31 16:17   ` Eric Botcazou
2019-06-03 10:38   ` Eric Botcazou
2019-06-04 15:06     ` Richard Biener [this message]

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='CAFiYyc21XMZ9vDWhjkVyTw+yYFFzVKt8rJ=gHkC4BgZ5CmS7Pw@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).