public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104196] [12 Regression] wrong code at -O2 and above on x86_64-linux-gnu
Date: Mon, 24 Jan 2022 00:37:45 +0000	[thread overview]
Message-ID: <bug-104196-4-VmyX6okeMR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104196-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is one which shows the issue just in case fold gets in the way:
int a = 6;
int main() {
    for (;;)
    {
        int c = 111;
        if (a < 0)
            c = -__INT_MAX__ - a;
        int b = a;
        if (a >= 0 || c > 0)
            b = 0;
        if (b != 4096 - __INT_MAX__) {
            if (a < 6)
                __builtin_abort ();
            return 0;
        }
    }
}

The main point is the undefined behavior of -__INT_MAX__ - a when a is not less
than 0 which is not true here as a is always 6.

Also for some reason using the C++ front-end also works around the issue ...
(but I don't see how though).

  parent reply	other threads:[~2022-01-24  0:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24  0:01 [Bug c/104196] New: " cnsun at uwaterloo dot ca
2022-01-24  0:17 ` [Bug middle-end/104196] " jakub at gcc dot gnu.org
2022-01-24  0:17 ` [Bug tree-optimization/104196] [12 Regression] " jakub at gcc dot gnu.org
2022-01-24  0:37 ` pinskia at gcc dot gnu.org [this message]
2022-01-24  1:52 ` pinskia at gcc dot gnu.org
2022-01-24  2:00 ` pinskia at gcc dot gnu.org
2022-01-24  2:17 ` pinskia at gcc dot gnu.org
2022-01-24  2:19 ` pinskia at gcc dot gnu.org
2022-01-24  5:58 ` belyshev at depni dot sinp.msu.ru
2022-01-24 16:12 ` jakub at gcc dot gnu.org
2022-01-26 10:52 ` jakub at gcc dot gnu.org
2022-01-26 14:07 ` jakub at gcc dot gnu.org
2022-01-27  9:47 ` cvs-commit at gcc dot gnu.org
2022-01-27 10:20 ` 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-104196-4-VmyX6okeMR@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).