From: "Bin.Cheng" <amker.cheng@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix tree-loop-distribution.c ICE with -ftrapv (PR tree-optimization/89278)
Date: Fri, 15 Feb 2019 08:16:00 -0000 [thread overview]
Message-ID: <CAHFci29MF2Q6Fr-6jU=OWdbs61O55OWaogUOA7CTw1=evhdURg@mail.gmail.com> (raw)
In-Reply-To: <20190215074845.GR2135@tucnak>
On Fri, Feb 15, 2019 at 3:48 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Fri, Feb 15, 2019 at 08:33:44AM +0100, Jakub Jelinek wrote:
> > On Fri, Feb 15, 2019 at 03:25:33PM +0800, Bin.Cheng wrote:
> > > So with what condition we can safely rewrite trapping operations into
> > > non trapping one? Does the rewrite nullify -ftrapv which requires
> > > trap behavior?
> >
> > For the particular expression? Yes, otherwise no.
> >
> > -ftrapv should be either replaced with -fsanitize=signed-integer-overflow
> > -fsanitize-undefined-trap-on-error, or at least implemented that way in the
> > middle-end (perhaps with a separate ifn, so that we can pattern recognize it
> > during expansion and use library calls where the inline call is not small
> > enough). We haven't done that yet though.
>
> To clarify, the current -ftrapv implementation doesn't guarantee you get
> traps on overflow, it will happily optimize computations away at any time
> during GIMPLE optimizations, or turn stuff into unsigned computations etc.
> (not just through this rewrite function, but many other ways).
> For -fsanitize=signed-integer-overflow -fsanitize-undefined-trap-on-error
> there are no guarantees either, but we try hard not to optimize those away,
> we have TYPE_OVERFLOW_SANITIZED checks that punt certain optimizations in
> fold-const.c/match.pd and early (right after going into ssa form) we turn
> the arithmetics into ifns, which are optimized away only if we can prove
> there will be no overflow. On the other side, it can hinder other
> optimizations (a lot). And possibly overflowing computations introduced
> during later optimizations are not sanitized.
> The question is what -ftrapv users want, plus right now they have a choice,
> catch perhaps less UB with more optimization opportunities (-ftrapv)
> or catch more optimize less (UBSan).
Thanks very much for the explanation, that explains all questions I had.
Thanks,
bin
>
> Jakub
prev parent reply other threads:[~2019-02-15 8:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 22:52 Jakub Jelinek
2019-02-15 7:03 ` Richard Biener
2019-02-15 7:25 ` Bin.Cheng
2019-02-15 7:33 ` Jakub Jelinek
2019-02-15 7:49 ` Jakub Jelinek
2019-02-15 8:16 ` Bin.Cheng [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='CAHFci29MF2Q6Fr-6jU=OWdbs61O55OWaogUOA7CTw1=evhdURg@mail.gmail.com' \
--to=amker.cheng@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
/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).