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/114323] New: [14 Regression] MVE vector load intrinsic miscompiled since r14-5622-g4d7647edfd7d98
Date: Wed, 13 Mar 2024 11:42:23 +0000	[thread overview]
Message-ID: <bug-114323-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114323
           Summary: [14 Regression] MVE vector load intrinsic miscompiled
                    since r14-5622-g4d7647edfd7d98
           Product: gcc
           Version: 14.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: ---

The following testcase:

#include <arm_mve.h>

uint32x4_t foo (void) {
  uint32x4_t V0 = vld1q_u32(((const uint32_t[4]){1, 2, 3, 4}));
  return V0;
}

is miscompiled with -O2 -march=armv8.1-m.main+mve -mfloat-abi=hard on
arm-none-eabi.  Since r14-5622-g4d7647edfd7d985fbefe13de03c8bc2e3a74fc61 we
generate:

foo:
        sub     sp, sp, #16
        vldrw.32        q0, [sp]
        add     sp, sp, #16
        bx      lr

i.e. we do a vector load from uninitialized stack memory.  GCC 13 used to give:

foo:
        sub     sp, sp, #16
        mov     ip, sp
        ldr     r3, .L4
        ldm     r3, {r0, r1, r2, r3}
        stm     ip, {r0, r1, r2, r3}
        vldrw.32        q0, [ip]
        add     sp, sp, #16
        bx      lr
        .align  2
.L4:
        .word   .LANCHOR0
        .size   foo, .-foo
        .section        .rodata
        .align  2
        .set    .LANCHOR0,. + 0
        .word   1
        .word   2
        .word   3
        .word   4

which, while not optimal, is at least correct.  Here is a full executable
testcase for the testsuite:

#include <arm_mve.h>

__attribute__((noipa))
uint32x4_t foo (void) {
  uint32x4_t V0 = vld1q_u32(((const uint32_t[4]){1, 2, 3, 4}));
  return V0;
}

int main(void)
{
  uint32_t buf[4];
  vst1q_u32 (buf, foo());

  for (int i = 0; i < 4; i++)
    if (buf[i] != i+1)
      __builtin_abort ();
}

             reply	other threads:[~2024-03-13 11:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 11:42 acoplan at gcc dot gnu.org [this message]
2024-03-13 12:03 ` [Bug target/114323] " acoplan at gcc dot gnu.org
2024-03-13 12:11 ` rguenth at gcc dot gnu.org
2024-03-13 13:37 ` law at gcc dot gnu.org
2024-03-14  7:44 ` clyon at gcc dot gnu.org
2024-03-15  5:59 ` prathamesh3492 at gcc dot gnu.org
2024-03-15 11:17 ` acoplan at gcc dot gnu.org
2024-03-15 11:31 ` clyon at gcc dot gnu.org
2024-03-19  8:19 ` cvs-commit at gcc dot gnu.org
2024-03-19  8:20 ` clyon 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-114323-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).