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/103986] [9/10 Regression] Miscompilation with -O2 -funswitch-loops and __builtin_unreachable
Date: Wed, 12 Jan 2022 07:08:04 +0000	[thread overview]
Message-ID: <bug-103986-4-AqwjxdGXId@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103986-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-12
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Those come from dom3.

Here is a testcase which runs in finite time to test this (plus it is not a C
testcase also):
#define assume(Expression) do { if((Expression)) (void)0; else
__builtin_unreachable(); } while(0)
struct GridZYXIterator {        
        short x;
        short y;
        short z;
};
static inline
void f(struct GridZYXIterator *t) {
    t->x++;
    if(t->x == 3) {
        t->x = 0;
        t->y++;
        if(t->y == 3) {
            t->y = 0;
            t->z++;
        }
    }
}
static int t = 0;
static void g() __attribute__((noipa));
static void g(){t++; if (t > 27) __builtin_abort();};
int main()
{
        struct GridZYXIterator it = {0,0,0};
        while(it.z != 3) {
        assume(it.y < 3 && it.z < 3);
                g();
                f(&it);
        }       
}

Confirmed.

  parent reply	other threads:[~2022-01-12  7:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12  3:38 [Bug tree-optimization/103986] New: Miscompilation with -O2 -funswitch-loops and __builtin_unreachable in ternary operator daniel at constexpr dot org
2022-01-12  3:54 ` [Bug tree-optimization/103986] [9/10 Regression] " pinskia at gcc dot gnu.org
2022-01-12  3:54 ` pinskia at gcc dot gnu.org
2022-01-12  3:59 ` [Bug tree-optimization/103986] [9/10 Regression] Miscompilation with -O2 -funswitch-loops and __builtin_unreachable pinskia at gcc dot gnu.org
2022-01-12  4:05 ` pinskia at gcc dot gnu.org
2022-01-12  6:29 ` pinskia at gcc dot gnu.org
2022-01-12  6:36 ` pinskia at gcc dot gnu.org
2022-01-12  6:38 ` pinskia at gcc dot gnu.org
2022-01-12  7:08 ` pinskia at gcc dot gnu.org [this message]
2022-01-12  7:11 ` pinskia at gcc dot gnu.org
2022-01-12  8:17 ` rguenth at gcc dot gnu.org
2022-01-12  8:20 ` rguenth 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-103986-4-AqwjxdGXId@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).