public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/104882] New: [12 Regression] MVE: Wrong code at -O2 since r12-1434-g046a3beb1673bf4a61c131373b6a5e84158e92bf
@ 2022-03-11 14:18 acoplan at gcc dot gnu.org
  2022-03-11 14:21 ` [Bug target/104882] " acoplan at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: acoplan at gcc dot gnu.org @ 2022-03-11 14:18 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-03 19:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 14:18 [Bug target/104882] New: [12 Regression] MVE: Wrong code at -O2 since r12-1434-g046a3beb1673bf4a61c131373b6a5e84158e92bf acoplan at gcc dot gnu.org
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

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).