public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vsevolod.livinskij at frtk dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/104551] New: Wrong code with -O3 for skylake-avx512, icelake-server, and sapphirerapids
Date: Tue, 15 Feb 2022 18:01:23 +0000	[thread overview]
Message-ID: <bug-104551-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 104551
           Summary: Wrong code with -O3 for skylake-avx512,
                    icelake-server, and sapphirerapids
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

Reproducer (I was not able to merge it into a single file):
// func.cpp
extern unsigned var_11, var_178;
extern unsigned char arr_492[];
void test() {
  for (bool a = 0; a < (bool)var_11; a = 2)
    for (unsigned b = 0; b < var_11;
         b += 1)
      var_178 = arr_492[b] ? arr_492[b] : (char) b;
}

// driver.cpp 
unsigned int var_11 = 16U;
unsigned int var_178 = 0;
unsigned char arr_492 [16];

void test();

int main() {
    for (int i = 0; i < 16; ++i)
        arr_492 [i] = (unsigned char)128;
    test();
    __builtin_printf("%u\n", var_178);
    if (var_178 != 128)
        __builtin_abort();
    return 0;
}

Error:
>$ g++ -O0 func.cpp driver.cpp -march=skylake-avx512 && sde -skx -- ./a.out 
128
>$ g++ -O3 func.cpp driver.cpp -march=skylake-avx512 && sde -skx -- ./a.out 
4294967168
Aborted (core dumped)

g++ (git://gcc.gnu.org/git/gcc.git:master
58aeb75d4097010ad9bb72b964265b18ab284f93) 12.0.1 20220213 (experimental)

             reply	other threads:[~2022-02-15 18:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 18:01 vsevolod.livinskij at frtk dot ru [this message]
2022-02-15 23:21 ` [Bug tree-optimization/104551] [12 Regression] " pinskia at gcc dot gnu.org
2022-02-16  1:52 ` crazylht at gmail dot com
2022-02-16  2:34 ` crazylht at gmail dot com
2022-02-16  3:57 ` crazylht at gmail dot com
2022-02-17 11:01 ` cvs-commit at gcc dot gnu.org
2022-02-17 11:02 ` crazylht at gmail dot com
2022-02-18  0:37 ` pinskia 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-104551-4@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).