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 middle-end/110228] [13/14 Regression] llvm-16 miscompiled due to an maybe uninitialized and optimizations saying that the uninitialized has a nonzero bits of 1.
Date: Sat, 17 Jun 2023 21:38:57 +0000	[thread overview]
Message-ID: <bug-110228-4-ewQs8hAcYs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110228-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[14 Regression] llvm-16     |[13/14 Regression] llvm-16
                   |miscompiled due to an maybe |miscompiled due to an maybe
                   |uninitialized and           |uninitialized and
                   |optimizations saying that   |optimizations saying that
                   |the uninitialized has a     |the uninitialized has a
                   |nonzero bits of 1.          |nonzero bits of 1.
   Target Milestone|14.0                        |13.2

--- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is a (x86_64 as it requires the inline-asm to force an undefined value
inside LookupFlags but LookupFlags is not used until the next iteration)
program which we have been miscompiling -O2 since r13-4459-g6508d5e5a1a8:
```
unsigned a[4] = {1,1,1,1};

unsigned tt1 = 0;
__attribute__((noipa))
static void bug(unsigned & p, unsigned *t, int n, int t2) {

    for(int i = 0; i < n; i++) {
        bool LookupFlags ;
        unsigned v = t[i];
        unsigned tt = tt1;
      if (v == 0)
        LookupFlags = 0;
     else if (v == 1)
        LookupFlags = 1;
     if (LookupFlags) {
        tt|=3u;
        LookupFlags = 0;
     }
     asm("movq $-1, %q1":"+a"(LookupFlags));
       p = tt;
    }
}


int main() {
    unsigned r = 42;
    bug(r,a, sizeof(a)/sizeof(a[0]), 1);
    __builtin_printf("%u\n", r);
    if (r != 3) __builtin_abort();
}
```

Yes it is a bit odd but that was the only way I could get the code added in
r13-4459-g6508d5e5a1a8 to be invoked and even have LookupFlags|=v==1 happening
and get what could get undefined behavior in the loop.

  parent reply	other threads:[~2023-06-17 21:38 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 17:19 [Bug middle-end/110228] New: [14 Regression] llvm-16 miscompilation on small case switch, minimized slyfox at gcc dot gnu.org
2023-06-12 17:27 ` [Bug middle-end/110228] " pinskia at gcc dot gnu.org
2023-06-12 17:30 ` pinskia at gcc dot gnu.org
2023-06-12 17:32 ` pinskia at gcc dot gnu.org
2023-06-12 17:39 ` pinskia at gcc dot gnu.org
2023-06-12 17:45 ` pinskia at gcc dot gnu.org
2023-06-12 17:49 ` pinskia at gcc dot gnu.org
2023-06-12 19:03 ` [Bug middle-end/110228] [14 Regression] llvm-16 miscompiled due to an maybe uninitialized and optimizations saying that the uninitialized has a nonzero bits of 1 pinskia at gcc dot gnu.org
2023-06-12 19:17 ` pinskia at gcc dot gnu.org
2023-06-15  4:50 ` pinskia at gcc dot gnu.org
2023-06-16 22:18 ` pinskia at gcc dot gnu.org
2023-06-16 22:23 ` pinskia at gcc dot gnu.org
2023-06-17 17:52 ` pinskia at gcc dot gnu.org
2023-06-17 20:52 ` pinskia at gcc dot gnu.org
2023-06-17 20:56 ` slyfox at gcc dot gnu.org
2023-06-17 21:04 ` jakub at gcc dot gnu.org
2023-06-17 21:38 ` pinskia at gcc dot gnu.org [this message]
2023-06-20  8:38 ` [Bug middle-end/110228] [13/14 " aldyh at gcc dot gnu.org
2023-06-24  0:01 ` [Bug middle-end/110228] [13/14 Regression] llvm-16 miscompiled due to an maybe uninitialized variable pinskia at gcc dot gnu.org
2023-06-30  2:19 ` pinskia at gcc dot gnu.org
2023-07-01  5:24 ` pinskia at gcc dot gnu.org
2023-07-01 21:37 ` zhendong.su at inf dot ethz.ch
2023-07-01 21:40 ` pinskia at gcc dot gnu.org
2023-07-01 21:50 ` pinskia at gcc dot gnu.org
2023-07-03 21:04 ` slyfox at gcc dot gnu.org
2023-07-03 21:52 ` slyfox at gcc dot gnu.org
2023-07-04  6:33 ` rguenth at gcc dot gnu.org
2023-07-04  6:54 ` rguenth at gcc dot gnu.org
2023-07-04  9:15 ` cvs-commit at gcc dot gnu.org
2023-07-04  9:18 ` rguenth at gcc dot gnu.org
2023-07-04 10:06 ` zhendong.su at inf dot ethz.ch
2023-07-04 10:28 ` rguenth at gcc dot gnu.org
2023-07-04 13:36 ` slyfox at gcc dot gnu.org
2023-07-04 13:41 ` rguenther at suse dot de
2023-07-04 15:11 ` slyfox at gcc dot gnu.org
2023-07-05  7:29 ` [Bug middle-end/110228] [13 " rguenth at gcc dot gnu.org
2023-07-05  8:23 ` cvs-commit at gcc dot gnu.org
2023-07-05  8:24 ` 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-110228-4-ewQs8hAcYs@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).