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

--- Comment #3 from Xiao Ma <mxlol233 at outlook dot com> ---
Created attachment 56185
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56185&action=edit
a patch on releases/gcc-13 to reproduce the bug.

steps:
1. git clone -b releases/gcc-13 https://github.com/gcc-mirror/gcc.git
2. cd gcc
3. #apply this patch
4. mkdir .build_accel && cd .build_accel && ../configure --target=rvgpu-none
--enable-languages=c --enable-as-accelerator-for=x86_64-pc-linux-gnu && make
all-gcc -j16
5. cd ../
6. mkdir .build_host && cd .build_host && ../configure --enable-languages=c
--enable-offload-targets=rvgpu-none=`pwd`/../../.install/rvgpu-none/ && make
all-gcc -j16
7. cd ../ && mkdir .tmp && cd .tmp
8. # touch a file:

```
/* { dg-do run } */


int
main (void)
{
  int i2, l = 0, r = 0, l2 = 0;
  int a[3][3][3];


  #pragma acc parallel
  #pragma acc loop collapse(4 - 1)
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          a[i][j][k] = i + j * 4 + k * 16;
#pragma acc parallel
    {
      #pragma acc loop collapse(2) reduction(|:l)
        for (i2 = 0; i2 < 2; i2++)
          for (int j = 0; j < 2; j++)
            for (int k = 0; k < 2; k++)
              if (a[i2][j][k] != i2 + j * 4 + k * 16)
                l += 1;
    }

  /*  Test loop with >= condition.  */
#pragma acc parallel
    {
      #pragma acc loop collapse(2) reduction(|:l2)
        for (i2 = 0; i2 < 2; i2++)
          for (int j = 1; j >= 0; j--)
            for (int k = 0; k < 2; k++)
              if (a[i2][j][k] != i2 + j * 4 + k * 16)
                l2 += 1;
    }

    for (i2 = 0; i2 < 2; i2++)
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          if (a[i2][j][k] != i2 + j * 4 + k * 16)
            r += 1;


  return 0;
}


```
9. ../.build_host/gcc/cc1 -fopenacc  -quiet  -o a.s a.c
# you will see the log like this:
```NUM_POLY_INT_COEFFS=1
```
10. as --64 -o a.o a.s

11. ../.build_accel/gcc/lto1 -quiet  -o a.o.s a.o                               
# you will see the log like this:
```
NUM_POLY_INT_COEFFS=2
‘
Segmentation fault
0xbf3e83 crash_signal
        ../../gcc/toplev.cc:314
0x7f92986f608f ???
       
/build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f929883b6e5 ???
        ../sysdeps/x86_64/multiarch/strlen-avx2.S:65
0x1773512 pp_quoted_string
        ../../gcc/pretty-print.cc:1845
0x177435a pp_format(pretty_printer*, text_info*)
        ../../gcc/pretty-print.cc:1359
0x176495f diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ../../gcc/diagnostic.cc:1592
0x1765149 diagnostic_impl
        ../../gcc/diagnostic.cc:1756
0x1767236 fatal_error(unsigned int, char const*, ...)
        ../../gcc/diagnostic.cc:2141
0xa90e11 lto_input_mode_table(lto_file_decl_data*)
        ../../gcc/lto-streamer-in.cc:2103
0x748626 lto_file_finalize
        ../../gcc/lto/lto-common.cc:2275
0x748626 lto_create_files_from_ids
        ../../gcc/lto/lto-common.cc:2298
0x748626 lto_file_read
        ../../gcc/lto/lto-common.cc:2353
0x748626 read_cgraph_and_symbols(unsigned int, char const**)
        ../../gcc/lto/lto-common.cc:2801
0x735356 lto_main()
        ../../gcc/lto/lto.cc:654
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

Reply via email to