[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1071140: gcc-14: internal compiler error: in find_or_generate_expression, at tree-ssa-pre.cc:2780 on riscv64



> Source: gcc-14
> Version: 14-20240429-1
> Severity: important
> X-Debbugs-Cc: numbksco@gmail.com
> 
> Dear Maintainer,
> 
> We found a gcc internal compiler error when compile a c source code(from
> ksco):
> 
> 
> ```
&gt; #include <riscv_vector.h>
&gt; typedef int npy_intp;
&gt; static inline __attribute__(()) int vaddq_f32();
&gt; static inline __attribute__(()) int npyv_load2_tillz_f32(int nlane) {
&gt;   vint32m1_t __trans_tmp_9;
&gt;   {
&gt;     int __trans_tmp_10 = nlane;
&gt;     {
&gt;       vint32m1_t __trans_tmp_8;
&gt;       vint64m1_t __trans_tmp_6;
&gt;       vint64m1_t __trans_tmp_4;
&gt;       vint64m1_t __trans_tmp_3;
&gt;       vint64m1_t __trans_tmp_2;
&gt;       vint64m1_t __trans_tmp_1;
&gt;       if (__trans_tmp_10 == 1) {
&gt;         {
&gt;           __trans_tmp_3 =
&gt;               __riscv_vslideup_vx_i64m1(__trans_tmp_1, __trans_tmp_2, 1, 2);
&gt;         }
&gt;         __trans_tmp_4 = __trans_tmp_3;
&gt;       }
&gt;       __trans_tmp_6 = __trans_tmp_3;
&gt;       __trans_tmp_8 = __riscv_vreinterpret_v_i64m1_i32m1(__trans_tmp_3);
&gt;       __trans_tmp_9 = __trans_tmp_8;
&gt;     }
&gt;   }
&gt;   return vaddq_f32(__trans_tmp_9);
&gt; }
&gt; char CFLOAT_add_args_2;
&gt; char CFLOAT_add_args_1;
&gt; char CFLOAT_add_args_0;
&gt; const npy_intp *CFLOAT_add_dimensions;
&gt; const npy_intp *CFLOAT_add_steps;
&gt; const npy_intp CFLOAT_add_steps_0;
&gt; __attribute__(()) void CFLOAT_add() {
&gt;   npy_intp len = CFLOAT_add_dimensions[0];
&gt;   char *b_src0 = &amp;CFLOAT_add_args_0, *b_src1 = &amp;CFLOAT_add_args_1,
&gt;        *b_dst = &amp;CFLOAT_add_args_2;
&gt;   const float *src1 = (float *)b_src1;
&gt;   float *dst = (float *)b_dst;
&gt;   const npy_intp ssrc1 = CFLOAT_add_steps[1] / sizeof(float);
&gt;   const npy_intp sdst = CFLOAT_add_steps[2] / sizeof(float);
&gt;   const int hstep = 4 / 2;
&gt;   {
&gt;     vfloat32m1x2_t a;
&gt;     ssrc1 == 2 &amp;&amp; sdst == ssrc1;
&gt;     for (; len &gt; 0; len -= hstep, src1 += 4, dst += 4) {
&gt;       int b = npyv_load2_tillz_f32(len);
&gt;       int r = vaddq_f32(a.__val[0], b);
&gt;     }
&gt;   }
&gt;   for (; len &gt; 0; --len, b_src0 += CFLOAT_add_steps_0,
&gt;                   b_src1 += CFLOAT_add_steps[1], b_dst += CFLOAT_add_steps[2])
&gt;     ;
&gt; }
&gt; 
&gt; ```
&gt; error:
&gt; 
&gt; ```
&gt; gcc-14 -c -O2 -w -march=rv64gcv test.c
&gt; during GIMPLE pass: pre
&gt; test.c: In function ‘CFLOAT_add’:
&gt; test.c:35:24: internal compiler error: in find_or_generate_expression, at tree-ssa-pre.cc:2780
&gt;    35 | __attribute__(()) void CFLOAT_add() {
&gt;       |                        ^~~~~~~~~~
&gt; 0xe5d75f find_or_generate_expression
&gt;         ../../src/gcc/tree-ssa-pre.cc:2780
&gt; 0xe5d97b find_or_generate_expression
&gt;         ../../src/gcc/tree-ssa-pre.cc:2777
&gt; 0xe5d97b create_component_ref_by_pieces_1
&gt;         ../../src/gcc/tree-ssa-pre.cc:2696
&gt; 0xe5cdc5 create_component_ref_by_pieces
&gt;         ../../src/gcc/tree-ssa-pre.cc:2764
&gt; 0xe5cdc5 create_expression_by_pieces
&gt;         ../../src/gcc/tree-ssa-pre.cc:2933
&gt; 0xe63275 do_hoist_insertion
&gt;         ../../src/gcc/tree-ssa-pre.cc:3762
&gt; 0xe63275 insert
&gt;         ../../src/gcc/tree-ssa-pre.cc:3907
&gt; 0xe63275 execute
&gt;         ../../src/gcc/tree-ssa-pre.cc:4499
&gt; Please submit a full bug report, with preprocessed source (by using -freport-bug).
&gt; Please include the complete backtrace with any bug report.
&gt; See <file: usr="" share="" doc="" gcc-14="" readme.bugs=""> for instructions.
&gt; ```
&gt; 
&gt; Please tell me if I can do help here.
&gt; 
&gt; -- 
&gt; Regards,
&gt; --
&gt;   Bo YU

We had verified this bug in the latest gcc version(https://godbolt.org/z/85YTbdjz4), this is a gcc bug due to gcc assert
tree_ssa option should equal to SSA_NAME at any time, but in riscv port the code calling break the assert.

We will try to fix this in gcc upstream recently, thanks for your reporting.

BR,
Jiawei</file:></riscv_vector.h>

Reply to: