public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104356] [12 Regression] divide by zero trap is being removed now when it should not be in some cases
Date: Thu, 03 Feb 2022 11:56:09 +0000	[thread overview]
Message-ID: <bug-104356-4-XqXiYese8g@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104356-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104356

--- Comment #17 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Eric Botcazou from comment #14)
> > OK, so a division by zero is not invoking undefined behavior but is
> > well-defined and traps.  And the idea is that -fnon-call-exceptions alone
> > carries this over to middle-end semantics?  (I don't think it does that at
> > the moment, with or without the rev. in question)
> 
> Why?  It's exactly like any other trapping operation, see the numerous
> predicates in tree-eh.cc, most notably operation_could_trap_helper_p:
> 
>   switch (op)
>     {
>     case TRUNC_DIV_EXPR:
>     case CEIL_DIV_EXPR:
>     case FLOOR_DIV_EXPR:
>     case ROUND_DIV_EXPR:
>     case EXACT_DIV_EXPR:
>     case CEIL_MOD_EXPR:
>     case FLOOR_MOD_EXPR:
>     case ROUND_MOD_EXPR:
>     case TRUNC_MOD_EXPR:
>       if (!TREE_CONSTANT (divisor) || integer_zerop (divisor))
>         return true;

It's used for a different purpose as well, we of course have to avoid moving a
possibly trapping operation to a place where it was not executed
unconditionally.

But sure, so you say that -fnon-call-exceptions makes operations that
may trap according to the EH machinery well-defined, irrespective of what
the language standards say?  That certainly makes sense, it doesn't
make sense to create EH when the situation invokes undefined behavior.
(but as said above we have to avoid traps in non-EH context as well)

  parent reply	other threads:[~2022-02-03 11:56 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 22:56 [Bug tree-optimization/104356] New: " pinskia at gcc dot gnu.org
2022-02-02 22:57 ` [Bug tree-optimization/104356] " pinskia at gcc dot gnu.org
2022-02-02 23:08 ` jakub at gcc dot gnu.org
2022-02-03  7:32 ` rguenth at gcc dot gnu.org
2022-02-03  7:42 ` pinskia at gcc dot gnu.org
2022-02-03  7:43 ` pinskia at gcc dot gnu.org
2022-02-03  7:58 ` pinskia at gcc dot gnu.org
2022-02-03  8:34 ` rguenther at suse dot de
2022-02-03 10:40 ` ebotcazou at gcc dot gnu.org
2022-02-03 11:08 ` rguenther at suse dot de
2022-02-03 11:14 ` ebotcazou at gcc dot gnu.org
2022-02-03 11:22 ` jakub at gcc dot gnu.org
2022-02-03 11:41 ` ebotcazou at gcc dot gnu.org
2022-02-03 11:43 ` rguenth at gcc dot gnu.org
2022-02-03 11:45 ` jakub at gcc dot gnu.org
2022-02-03 11:48 ` ebotcazou at gcc dot gnu.org
2022-02-03 11:50 ` ebotcazou at gcc dot gnu.org
2022-02-03 11:52 ` rguenth at gcc dot gnu.org
2022-02-03 11:56 ` rguenth at gcc dot gnu.org [this message]
2022-02-03 12:00 ` rguenth at gcc dot gnu.org
2022-02-03 12:00 ` jakub at gcc dot gnu.org
2022-02-03 12:03 ` jakub at gcc dot gnu.org
2022-02-03 12:03 ` ebotcazou at gcc dot gnu.org
2022-02-03 12:05 ` ebotcazou at gcc dot gnu.org
2022-02-03 12:05 ` rguenther at suse dot de
2022-02-03 12:10 ` rguenth at gcc dot gnu.org
2022-02-03 12:13 ` jakub at gcc dot gnu.org
2022-02-03 12:18 ` ebotcazou at gcc dot gnu.org
2022-02-03 12:21 ` cvs-commit at gcc dot gnu.org
2022-02-03 12:28 ` ebotcazou at gcc dot gnu.org
2022-02-03 12:39 ` jakub at gcc dot gnu.org
2022-02-03 12:49 ` ebotcazou at gcc dot gnu.org
2022-02-03 12:51 ` ebotcazou at gcc dot gnu.org
2022-02-03 13:04 ` jakub at gcc dot gnu.org
2022-02-03 13:09 ` rguenther at suse dot de
2022-02-03 15:41 ` ebotcazou at gcc dot gnu.org
2022-02-03 16:28 ` [Bug tree-optimization/104356] [12 Regression] divide by zero trap incorrectly optimized away jakub at gcc dot gnu.org
2022-02-03 16:41 ` ebotcazou at gcc dot gnu.org
2022-02-03 16:51 ` amacleod at redhat dot com
2022-02-03 16:57 ` jakub at gcc dot gnu.org
2022-02-03 18:35 ` amacleod at redhat dot com
2022-02-04  7:08 ` rguenther at suse dot de
2022-02-04  7:11 ` rguenth at gcc dot gnu.org
2022-02-04 10:05 ` ebotcazou at gcc dot gnu.org
2022-02-04 11:10 ` cvs-commit at gcc dot gnu.org
2022-02-04 11:17 ` ebotcazou at gcc dot gnu.org
2022-02-04 13:46 ` amacleod at redhat dot com
2022-02-04 16:40 ` ebotcazou at gcc dot gnu.org
2022-02-04 16:45 ` cvs-commit at gcc dot gnu.org

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=bug-104356-4-XqXiYese8g@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).