public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "radek.barton at microsoft dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/113485] New: Segmentation fault in -fno-guess-branch-probability optimization of NEON instructions on aarch64-linux-gnu target
Date: Thu, 18 Jan 2024 15:01:04 +0000	[thread overview]
Message-ID: <bug-113485-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113485
           Summary: Segmentation fault in -fno-guess-branch-probability
                    optimization of NEON instructions on aarch64-linux-gnu
                    target
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: radek.barton at microsoft dot com
  Target Milestone: ---

Created attachment 57140
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57140&action=edit
neon-issue.i

Hello everyone.

When code with certain combination of NEON instructions intrinsics is compiled
for `aarch64-linux-gnu` target with at least `-O1` optimizations enabled, the
compilation fails with:

```
during RTL pass: split1
neon-issue.c:23:1: internal compiler error: Segmentation fault
   23 | }
      | ^
0xdd5ac3 crash_signal
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/toplev.cc:317
0x7f5e7aa0851f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x9e1c4d mark_label_nuses
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/emit-rtl.cc:3896
0x9e1cca mark_label_nuses
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/emit-rtl.cc:3907
0x9e1c99 mark_label_nuses
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/emit-rtl.cc:3904
0x9e7779 try_split(rtx_def*, rtx_insn*, int)
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/emit-rtl.cc:4093
0xd3fdd1 split_insn
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/recog.cc:3405
0xd44daf split_all_insns()
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/recog.cc:3509
0xd44e5c execute
        /home/blackhex/mingw-woarm64-build/code/gcc-master/gcc/recog.cc:4433
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
```

I've reproduced the issue on a recent master branch
(9a5e8f9d112adb0fdd0931f72a023cd77c09dd8c) from git://gcc.gnu.org/git/gcc.git
compiled with:

```
configure --prefix=/home/blackhex/cross-aarch64-linux-gnu-libc
--target=aarch64-linux-gnu
--includedir=/home/blackhex/cross-aarch64-linux-gnu-libc/aarch64-linux-gnu/include
--enable-languages=c,lto,c++,fortran --enable-shared --enable-static
--enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes
--enable-cloog-backend=isl --enable-version-specific-runtime-libs --enable-lto
--enable-libgomp --enable-checking=release --disable-multilib --disable-shared
--disable-rpath --disable-werror --disable-symvers --disable-libstdcxx-pch
--disable-libstdcxx-debug --disable-isl-version-check --disable-bootstrap
--with-libiconv --with-system-zlib --with-gnu-as --with-gnu-ld --enable-debug
```

when building libjpeg-turbo.

I've managed to narrow down that this regression was introduced by
74e3e839ab2d368413207455af2fdaaacc73842b commit.

The issue is not reproducible when -fno-guess-branch-probability optimization
is disabled.

The minimum repro-case, I've found, is:

```
#include <arm_neon.h>

void test()
{
  while (1)
  {
    static const uint16_t jsimd_rgb_ycc_neon_consts[] = {19595, 0, 0, 0, 0, 0,
0, 0};
    uint16x8_t consts = vld1q_u16(jsimd_rgb_ycc_neon_consts);

    uint8_t tmp_buf[0];
    uint8x8x3_t input_pixels = vld3_u8(tmp_buf);
    uint16x8_t r = vmovl_u8(input_pixels.val[1]);
    uint32x4_t y_l = vmull_laneq_u16(vget_low_u16(r), consts, 0);

    uint32x4_t s = vdupq_n_u32(1);
    uint16x4_t a = vrshrn_n_u32(s, 16);
    uint16x4_t y = vrshrn_n_u32(y_l, 16);
    uint16x8_t ay = vcombine_u16(a, y);

    unsigned char ***out_buf;
    vst1_u8(out_buf[1][0], vmovn_u16(ay));
  }
}
```
and the build command I used is:
```
/home/blackhex/cross-aarch64-linux-gnu-libc/bin/aarch64-linux-gnu-gcc \
    -O1 -Wall -Wextra \
    -c neon-issue.c \
    -freport-bug -save-temps
```

I am attaching the repro-case with the header expanded.

Radek Bartoň

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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18 15:01 radek.barton at microsoft dot com [this message]
2024-01-18 15:32 ` [Bug target/113485] " pinskia at gcc dot gnu.org
2024-01-18 15:33 ` [Bug target/113485] [14 regrssion] segmentation " pinskia at gcc dot gnu.org
2024-01-18 17:46 ` [Bug target/113485] [14 regrssion] ICE with -fno-guess-branch-probability on aarch64 starting with r14-7187-g74e3e839ab2d36 pinskia at gcc dot gnu.org
2024-01-19  7:11 ` rguenth at gcc dot gnu.org
2024-01-23 19:09 ` [Bug target/113485] [14 regression] " mkuvyrkov at gcc dot gnu.org
2024-01-24  3:18 ` pinskia at gcc dot gnu.org
2024-01-24  3:26 ` pinskia at gcc dot gnu.org
2024-01-24 13:49 ` jakub at gcc dot gnu.org
2024-01-24 14:48 ` rsandifo at gcc dot gnu.org
2024-01-25 12:03 ` cvs-commit at gcc dot gnu.org
2024-01-25 12:11 ` rsandifo 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-113485-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).