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

            Bug ID: 121075
           Summary: [16 Regression] RISC-V: ICE during GIMPLE pass: vect
                    segmentation fault with -flto
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ewlu at rivosinc dot com
  Target Milestone: ---

Testcase:
int a;
extern short b[];
void c(int d, int e, char f, signed char u[][25][25][25][25][25]) {
  for (_Bool v = 0; v < 1; v = e)
    for (int w = 0; w < 6; w += -7109)
      for (signed x = 0; x < 20; x += f + 115) {
        b[v] = u[x][7][4][1][3][x] ?: 10561592;
        a = a < d ? a : d;
      }
}
int d;
int e = 10348651;
char f = -114;
signed char u[5][25][25][25][25][25];
int main() {
  c(d, e, f, u);
}

Command/backtrace:
$
/scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
-I/scratch/ewlu/ci/compiler-fuzz-ci/csmith-build/include -fsigned-char
-fno-strict-aliasing -fwrapv -march=rv64gcv_zvl256b -flto -O3 red.c -o
rv64gcv.out -w -freport-bug
during GIMPLE pass: vect
red.c: In function 'main':
red.c:15:5: internal compiler error: Segmentation fault
   15 | int main() {
      |     ^
0x2d40b76 internal_error(char const*, ...)
        ../../../gcc/gcc/diagnostic-global-context.cc:517
0x136f713 crash_signal
        ../../../gcc/gcc/toplev.cc:321
0x77e7e064532f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x168e5a5 tree_check(tree_node const*, char const*, int, char const*,
tree_code)
        ../../../gcc/gcc/tree.h:4003
0x168e5a5 TYPE_VECTOR_SUBPARTS(tree_node const*)
        ../../../gcc/gcc/tree.h:4338
0x168e5a5 vect_set_loop_controls_directly
        ../../../gcc/gcc/tree-vect-loop-manip.cc:514
0x168e5a5 vect_set_loop_condition_partial_vectors
        ../../../gcc/gcc/tree-vect-loop-manip.cc:899
0x168e5a5 vect_set_loop_condition(loop*, edge_def*, _loop_vec_info*,
tree_node*, tree_node*, tree_node*, bool)
        ../../../gcc/gcc/tree-vect-loop-manip.cc:1410
0x16852db vect_transform_loop(_loop_vec_info*, gimple*)
        ../../../gcc/gcc/tree-vect-loop.cc:11663
0x16d30f8 vect_transform_loops
        ../../../gcc/gcc/tree-vectorizer.cc:1044
0x16d37a4 try_vectorize_loop_1
        ../../../gcc/gcc/tree-vectorizer.cc:1193
0x16d37a4 try_vectorize_loop
        ../../../gcc/gcc/tree-vectorizer.cc:1223
0x16d3eea execute
        ../../../gcc/gcc/tree-vectorizer.cc:1331
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.
lto-wrapper: fatal error:
/scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
returned 1 exit status
compilation terminated.
/scratch/ewlu/daily-upstream-build/build-gcv/lib/gcc/riscv64-unknown-linux-gnu/16.0.0/../../../../riscv64-unknown-linux-gnu/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Godbolt: https://godbolt.org/z/hhPKGE7hj

Found via fuzzer

Not sure if this is just a result of trying to link with undefined extern
variable or if there is something else going on

Reply via email to