public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "acoplan at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/104882] New: [12 Regression] MVE: Wrong code at -O2 since r12-1434-g046a3beb1673bf4a61c131373b6a5e84158e92bf
Date: Fri, 11 Mar 2022 14:18:38 +0000	[thread overview]
Message-ID: <bug-104882-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 104882
           Summary: [12 Regression] MVE: Wrong code at -O2 since
                    r12-1434-g046a3beb1673bf4a61c131373b6a5e84158e92bf
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acoplan at gcc dot gnu.org
  Target Milestone: ---

Created attachment 52608
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52608&action=edit
broken assembly output

The following code:

int i;
char src[1072];
char dst[72];
int main() {
  for (i = 0; i < 128; i++)
    src[i] = i;
  __builtin_memcpy(dst, src, 7);
  for (i = 0; i < 7; i++)
    if (dst[i] != i)
      __builtin_abort();
}

is miscompiled at -O2 since vectorization was enabled at -O2. With -O2
-ftree-vectorize, it is miscompiled earlier, starting with:

commit 046a3beb1673bf4a61c131373b6a5e84158e92bf
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date:   Thu Jun 3 15:35:50 2021

    arm: Auto-vectorization for MVE: add pack/unpack patterns

It looks like we do some dubious packing of vector elements before storing to
src. If I change the last loop to print the elements of dst instead, I see:

0 8 4 12 1 9 5

it should of course print:

0 1 2 3 4 5 6.

The broken code is attached. The testcase above was reduced from
gcc/testsuite/gcc.c-torture/execute/memcpy-1.c.

             reply	other threads:[~2022-03-11 14:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 14:18 acoplan at gcc dot gnu.org [this message]
2022-03-11 14:21 ` [Bug target/104882] " acoplan at gcc dot gnu.org
2022-03-14  5:39 ` pinskia at gcc dot gnu.org
2022-03-14  7:50 ` rguenth at gcc dot gnu.org
2022-03-16 14:40 ` clyon at gcc dot gnu.org
2022-03-22 14:37 ` clyon at gcc dot gnu.org
2022-03-25 17:27 ` cvs-commit at gcc dot gnu.org
2022-03-25 17:30 ` clyon at gcc dot gnu.org
2023-03-03 19:10 ` cvs-commit 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-104882-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).