public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/108365] [9/10/11/12/13 Regression] Wrong code with -O0
Date: Tue, 10 Jan 2023 23:36:27 +0000	[thread overview]
Message-ID: <bug-108365-4-r0CfrjIIcg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108365-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
With r9-1730 or later, I think the problem is that something decides to narrow
the division from long long to int.  In long long it is well defined if b is
non-zero
as -2147483648LL / -1LL is 2147483648LL.  But when we instead narrow it to
-2147483648 / -1 is UB which triggers division by zero exception.
We don't seem to narrow:
int
foo (int x, int y)
{
  return (long long) x / (long long) y;
}
so probably we do it only if the dividend is constant or something similar; if
yes, then the fix would be stop narrowing if the dividend is the minimum of the
narrower type.

  parent reply	other threads:[~2023-01-10 23:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 22:47 [Bug tree-optimization/108365] New: " vsevolod.livinskiy at gmail dot com
2023-01-10 22:55 ` [Bug tree-optimization/108365] " pinskia at gcc dot gnu.org
2023-01-10 22:55 ` pinskia at gcc dot gnu.org
2023-01-10 23:07 ` [Bug middle-end/108365] " jakub at gcc dot gnu.org
2023-01-10 23:15 ` pinskia at gcc dot gnu.org
2023-01-10 23:36 ` jakub at gcc dot gnu.org [this message]
2023-01-10 23:59 ` jakub at gcc dot gnu.org
2023-01-11 11:47 ` [Bug c++/108365] " jakub at gcc dot gnu.org
2023-01-11 12:10 ` rguenth at gcc dot gnu.org
2023-01-14  9:18 ` cvs-commit at gcc dot gnu.org
2023-01-14  9:23 ` [Bug c++/108365] [9/10/11/12 " jakub at gcc dot gnu.org
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
2023-02-10 18:00 ` [Bug c++/108365] [10/11 " jakub at gcc dot gnu.org
2023-05-02 20:14 ` cvs-commit at gcc dot gnu.org
2023-05-03  9:37 ` [Bug c++/108365] [10 " jakub at gcc dot gnu.org
2023-05-03 15:21 ` cvs-commit at gcc dot gnu.org
2023-05-04  7:23 ` jakub 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-108365-4-r0CfrjIIcg@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).