public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114172] New: ICE with riscv rvv VSETVL intrinsic
@ 2024-02-29 15:55 vogelm at buerokommunikation dot fernuni-hagen.de
  2024-03-04 10:50 ` [Bug target/114172] [13 only] " bruce at hoult dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vogelm at buerokommunikation dot fernuni-hagen.de @ 2024-02-29 15:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114172
           Summary: ICE with riscv rvv VSETVL intrinsic
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vogelm at buerokommunikation dot fernuni-hagen.de
  Target Milestone: ---

Created attachment 57576
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57576&action=edit
.i file generated from code in description

#pragma riscv intrinsic "vector"

void saxpy_rvv_m8(float *y, long vl)
{
    for (;;)
    {
        vl = __riscv_vsetvl_e32m8(vl); //ICE
        vfloat32m8_t y_vec;
        __riscv_vse32_v_f32m8(y, y_vec, vl);
    }
}

Description: 
The attached code snipped causes an ICE on about 4 out of 10 attempts on my
local machine. It seems to be related to the RVV intrinsic call
__riscv_vsetvl_e32m8(vl) on line 7.
Passing vl as a parameter here is a programming error, but I don't think the
compiler should crash. 
The behavior can also be observed on godbolt (https://godbolt.org/z/Gr915shzq).
I can reproduce the error on gcc 13.2.0 and 13.1.0.
gcc 14.0.1 doesn't crash so there already seems to be a fix for it but I
couldn't find any bug reports about it.

the exact version of GCC:
    gcc version 13.2.0 (gc891d8dc23e) 

the system type:
    riscv64-unknown-linux-gnu

the options given when GCC was configured/built;
    Configured with: $home/riscv-gnu-toolchain/gcc/configure 
        --target=riscv64-unknown-linux-gnu 
        --prefix=$home/riscv-gnu-toolchain/../_install 
        --with-sysroot=$home/riscv-gnu-toolchain/../_install/sysroot 
        --with-pkgversion=gc891d8dc23e 
        --with-system-zlib 
        --enable-shared 
        --enable-tls 
        --enable-languages=c,c++,fortran 
        --disable-libmudflap 
        --disable-libssp 
        --disable-libquadmath 
        --disable-libsanitizer 
        --disable-nls 
        --disable-bootstrap 
        --src=.././gcc 
        --enable-multilib 
        --with-abi=lp64d 
        --with-arch=rv64imafdcv 
        --with-tune=rocket 
        --with-isa-spec=20191213 'CFLAGS_FOR_TARGET=-O2    -mcmodel=medlow'
'CXXFLAGS_FOR_TARGET=-O2    -mcmodel=medlow'

the complete command line that triggers the bug;
    riscv64-unknown-linux-gnu-gcc -march=rv64imafdcv -mabi=lp64d -O3 -static -c
saxpy.c -o saxpy

the compiler output (error messages, warnings, etc.)
    riscv64-unknown-linux-gnu-gcc: internal compiler error: Segmentation fault
signal terminated program cc1

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

* [Bug target/114172] [13 only] ICE with riscv rvv VSETVL intrinsic
  2024-02-29 15:55 [Bug target/114172] New: ICE with riscv rvv VSETVL intrinsic vogelm at buerokommunikation dot fernuni-hagen.de
@ 2024-03-04 10:50 ` bruce at hoult dot org
  2024-03-29  2:05 ` wojciech_mula at poczta dot onet.pl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: bruce at hoult dot org @ 2024-03-04 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

Bruce Hoult <bruce at hoult dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bruce at hoult dot org

--- Comment #1 from Bruce Hoult <bruce at hoult dot org> ---
Even simpler version:

#pragma riscv intrinsic "vector"
void b(long c) {
  for (;;) {
    c = __riscv_vsetvl_e32m4(c);
    vfloat32m4_t d;
    e(c, d);
  }
}

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

* [Bug target/114172] [13 only] ICE with riscv rvv VSETVL intrinsic
  2024-02-29 15:55 [Bug target/114172] New: ICE with riscv rvv VSETVL intrinsic vogelm at buerokommunikation dot fernuni-hagen.de
  2024-03-04 10:50 ` [Bug target/114172] [13 only] " bruce at hoult dot org
@ 2024-03-29  2:05 ` wojciech_mula at poczta dot onet.pl
  2024-04-24 13:13 ` [Bug target/114172] [13 only] RISC-V: " cvs-commit at gcc dot gnu.org
  2024-04-24 13:19 ` kito at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: wojciech_mula at poczta dot onet.pl @ 2024-03-29  2:05 UTC (permalink / raw)
  To: gcc-bugs

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

Wojciech Mula <wojciech_mula at poczta dot onet.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wojciech_mula at poczta dot onet.p
                   |                            |l

--- Comment #2 from Wojciech Mula <wojciech_mula at poczta dot onet.pl> ---
Checked 13.2 from Debian:

$ riscv64-linux-gnu-gcc --version
riscv64-linux-gnu-gcc (Debian 13.2.0-12) 13.2.0

For the Bruce's testcase the following invocation triggers segfault (-O2, -O1,
-O2 - no error):

$ riscv64-linux-gnu-gcc -march=rv64gcv -c 1.c -O3

Below is just the bottom of stack obtained by gdb. There's an infinite
recursion somewhere around `riscv_vector::avl_info::operator==`.

#629078 0x0000000000fa3372 in
riscv_vector::avl_info::operator==(riscv_vector::avl_info const&) const ()
#629079 0x0000000000fa37f9 in ?? ()
#629080 0x0000000000fa2543 in ?? ()
#629081 0x0000000000fa3372 in
riscv_vector::avl_info::operator==(riscv_vector::avl_info const&) const ()
#629082 0x0000000000fa37f9 in ?? ()
#629083 0x0000000000fa2543 in ?? ()
#629084 0x0000000000fa3372 in
riscv_vector::avl_info::operator==(riscv_vector::avl_info const&) const ()
#629085 0x0000000000fa37f9 in ?? ()
#629086 0x0000000000fa2543 in ?? ()
#629087 0x0000000000fa3372 in
riscv_vector::avl_info::operator==(riscv_vector::avl_info const&) const ()
#629088 0x0000000000fa37f9 in ?? ()
#629089 0x0000000000fa2543 in ?? ()
#629090 0x0000000000fa3372 in
riscv_vector::avl_info::operator==(riscv_vector::avl_info const&) const ()
#629091 0x0000000000fa394b in ?? ()
#629092 0x0000000000f9f588 in
riscv_vector::vector_insn_info::compatible_p(riscv_vector::vector_insn_info
const&) const ()
#629093 0x0000000000fa0eb9 in
pass_vsetvl::compute_local_backward_infos(rtl_ssa::bb_info const*) ()
#629094 0x0000000000fa8c6b in pass_vsetvl::lazy_vsetvl() ()
#629095 0x0000000000fa8e1f in pass_vsetvl::execute(function*) ()
#629096 0x0000000000b5e21b in execute_one_pass(opt_pass*) ()
#629097 0x0000000000b5eac0 in ?? ()
#629098 0x0000000000b5ead2 in ?? ()
#629099 0x0000000000b5ead2 in ?? ()
#629100 0x0000000000b5eaf9 in execute_pass_list(function*, opt_pass*) ()
#629101 0x0000000000822588 in cgraph_node::expand() ()
#629102 0x0000000000823afb in ?? ()
#629103 0x0000000000825fd8 in symbol_table::finalize_compilation_unit() ()
#629104 0x0000000000c29bad in ?? ()
#629105 0x00000000006a4c97 in toplev::main(int, char**) ()
#629106 0x00000000006a6a8b in main ()

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

* [Bug target/114172] [13 only] RISC-V: ICE with riscv rvv VSETVL intrinsic
  2024-02-29 15:55 [Bug target/114172] New: ICE with riscv rvv VSETVL intrinsic vogelm at buerokommunikation dot fernuni-hagen.de
  2024-03-04 10:50 ` [Bug target/114172] [13 only] " bruce at hoult dot org
  2024-03-29  2:05 ` wojciech_mula at poczta dot onet.pl
@ 2024-04-24 13:13 ` cvs-commit at gcc dot gnu.org
  2024-04-24 13:19 ` kito at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-24 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Kito Cheng <kito@gcc.gnu.org>:

https://gcc.gnu.org/g:67e50daa5bd05f16d98c2dc651af2d6fa8335186

commit r13-8644-g67e50daa5bd05f16d98c2dc651af2d6fa8335186
Author: Kito Cheng <kito.cheng@sifive.com>
Date:   Wed Apr 24 16:54:44 2024 +0800

    RISC-V: Fix recursive vsetvli checking [PR114172]

    extract_single_source will recursive checking the sources to
    make sure if it's single source, however it may cause infinite
    recursive when the source is come from itself, so it should just skip
    first source to prevent that.

    NOTE: This logic has existing on trunk/GCC 14, but it included in a big
    vsetvli improvement patch, which is not backport to GCC 13.

    ```

    void saxpy_rvv_m8(float *y, long vl)
    {
        for (;;)
        {
            vl = __riscv_vsetvl_e32m8(vl); //ICE
            vfloat32m8_t y_vec;
            __riscv_vse32_v_f32m8(y, y_vec, vl);
        }
    }
    ```

    gcc/ChangeLog:

            PR target/114172
            * config/riscv/riscv-vsetvl.cc (extract_single_source):
            Skip first set.

    gcc/testsuite/ChangeLog:

            PR target/114172
            * gcc.target/riscv/rvv/vsetvl/pr114172.c: New.

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

* [Bug target/114172] [13 only] RISC-V: ICE with riscv rvv VSETVL intrinsic
  2024-02-29 15:55 [Bug target/114172] New: ICE with riscv rvv VSETVL intrinsic vogelm at buerokommunikation dot fernuni-hagen.de
                   ` (2 preceding siblings ...)
  2024-04-24 13:13 ` [Bug target/114172] [13 only] RISC-V: " cvs-commit at gcc dot gnu.org
@ 2024-04-24 13:19 ` kito at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: kito at gcc dot gnu.org @ 2024-04-24 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

Kito Cheng <kito at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Kito Cheng <kito at gcc dot gnu.org> ---
Fixed, and then gcc 13.3 will contain the fix, and that should release in near
future :)

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

end of thread, other threads:[~2024-04-24 13:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 15:55 [Bug target/114172] New: ICE with riscv rvv VSETVL intrinsic vogelm at buerokommunikation dot fernuni-hagen.de
2024-03-04 10:50 ` [Bug target/114172] [13 only] " bruce at hoult dot org
2024-03-29  2:05 ` wojciech_mula at poczta dot onet.pl
2024-04-24 13:13 ` [Bug target/114172] [13 only] RISC-V: " cvs-commit at gcc dot gnu.org
2024-04-24 13:19 ` kito 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).