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

            Bug ID: 125152
           Summary: [17 Regression] ICE: SIGSEGV in
                    riscv_expand_conditional_move (riscv.cc:5875) with -Oz
                    -mmovcc
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: riscv64-unknown-linux-gnu

Created attachment 64347
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64347&action=edit
reduced testcase

Compiler output:
$ riscv64-unknown-linux-gnu-gcc -Oz -mmovcc testcase.c -wrapper valgrind,-q
==2831435== Invalid read of size 2
==2831435==    at 0x1E377D5: riscv_expand_conditional_move(rtx_def*, rtx_def*,
rtx_def*, rtx_def*) (riscv.cc:5875)
==2831435==    by 0x259FE43: gen_movdicc(rtx_def*, rtx_def*, rtx_def*,
rtx_def*) (riscv.md:3406)
==2831435==    by 0x181DCA6: maybe_expand_insn (optabs.cc:8486)
==2831435==    by 0x181DCA6: emit_conditional_move_1(rtx_def*, rtx_def*,
rtx_def*, rtx_def*, machine_mode) (optabs.cc:5419)
==2831435==    by 0x181E12A: emit_conditional_move(rtx_def*, rtx_comparison,
rtx_def*, rtx_def*, machine_mode, int) (optabs.cc:5332)
==2831435==    by 0x14E11CB: expand_cond_expr_using_cmove(tree_node*,
tree_node*, tree_node*) (expr.cc:9713)
==2831435==    by 0x14CB1D3: expand_expr_real_2(separate_ops const*, rtx_def*,
machine_mode, expand_modifier) (expr.cc:11204)
==2831435==    by 0x14D4143: expand_expr_real_gassign(gassign*, rtx_def*,
machine_mode, expand_modifier, rtx_def**, bool) (expr.cc:11353)
==2831435==    by 0x14D2EAE: expand_expr_real_1(tree_node*, rtx_def*,
machine_mode, expand_modifier, rtx_def**, bool) (expr.cc:11543)
==2831435==    by 0x14E71C8: expand_expr_real (expr.cc:9619)
==2831435==    by 0x14E71C8: expand_normal (expr.h:329)
==2831435==    by 0x14E71C8: store_field(rtx_def*, poly_int<2u, long>,
poly_int<2u, long>, poly_int<2u, unsigned long>, poly_int<2u, unsigned long>,
machine_mode, tree_node*, int, bool, bool) (expr.cc:8336)
==2831435==    by 0x14E5FFF: store_constructor(tree_node*, rtx_def*, int,
poly_int<2u, long>, bool) (expr.cc:8186)
==2831435==    by 0x14E8168: expand_constructor(tree_node*, rtx_def*,
expand_modifier, bool) (expr.cc:9540)
==2831435==    by 0x14D13DF: expand_expr_real_1(tree_node*, rtx_def*,
machine_mode, expand_modifier, rtx_def**, bool) (expr.cc:11934)
==2831435==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==2831435==
during RTL pass: expand
testcase.c: In function 'foo':
testcase.c:8:5: internal compiler error: Segmentation fault
    8 |   v |= (V){4} > c;
      |     ^~
0x36d26ad internal_error(char const*, ...)
        /repo/gcc-trunk/gcc/diagnostic-global-context.cc:787
0x19c60ef crash_signal
        /repo/gcc-trunk/gcc/toplev.cc:325
0x1e377d5 riscv_expand_conditional_move(rtx_def*, rtx_def*, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/config/riscv/riscv.cc:5875
0x259fe43 gen_movdicc(rtx_def*, rtx_def*, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/config/riscv/riscv.md:3406
0x181dca6 maybe_expand_insn(insn_code, unsigned int, expand_operand*)
        /repo/gcc-trunk/gcc/optabs.cc:8486
0x181dca6 emit_conditional_move_1
        /repo/gcc-trunk/gcc/optabs.cc:5419
0x181e12a emit_conditional_move(rtx_def*, rtx_comparison, rtx_def*, rtx_def*,
machine_mode, int)
        /repo/gcc-trunk/gcc/optabs.cc:5332
0x14e11cb expand_cond_expr_using_cmove
        /repo/gcc-trunk/gcc/expr.cc:9713
0x14cb1d3 expand_expr_real_2(separate_ops const*, rtx_def*, machine_mode,
expand_modifier)
        /repo/gcc-trunk/gcc/expr.cc:11204
0x14d4143 expand_expr_real_gassign(gassign*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /repo/gcc-trunk/gcc/expr.cc:11353
0x14d2eae expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /repo/gcc-trunk/gcc/expr.cc:11543
0x14e71c8 expand_expr_real(tree_node*, rtx_def*, machine_mode, expand_modifier,
rtx_def**, bool)
        /repo/gcc-trunk/gcc/expr.cc:9619
0x14e71c8 expand_normal(tree_node*)
        /repo/gcc-trunk/gcc/expr.h:329
0x14e71c8 store_field
        /repo/gcc-trunk/gcc/expr.cc:8336
0x14e5fff store_constructor(tree_node*, rtx_def*, int, poly_int<2u, long>,
bool)
        /repo/gcc-trunk/gcc/expr.cc:8186
0x14e8168 expand_constructor
        /repo/gcc-trunk/gcc/expr.cc:9540
0x14d13df expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /repo/gcc-trunk/gcc/expr.cc:11934
0x14d4195 expand_expr_real_gassign(gassign*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /repo/gcc-trunk/gcc/expr.cc:11357
0x14d2eae expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        /repo/gcc-trunk/gcc/expr.cc:11543
0x14dedcd store_expr(tree_node*, rtx_def*, int, bool, bool)
        /repo/gcc-trunk/gcc/expr.cc:6803
/repo/gcc-trunk/binary-trunk-20260502093121-r17-273-g4188ac1ddb9ddd-checking-yes-rtl-df-extra-riscv64/bin/../libexec/gcc/riscv64-unknown-linux-gnu/17.0.0/cc1
-quiet -imultilib . -iprefix
/repo/gcc-trunk/binary-trunk-20260502093121-r17-273-g4188ac1ddb9ddd-checking-yes-rtl-df-extra-riscv64/bin/../lib/gcc/riscv64-unknown-linux-gnu/17.0.0/
testcase.c -quiet -dumpdir a- -dumpbase testcase.c -dumpbase-ext .c -mmovcc
-march=rv64imafdc_zmmul_zaamo_zalrsc_zca_zcd -mabi=lp64d -misa-spec=2.2
-mtls-dialect=trad -march=rv64imafdc_zmmul_zaamo_zalrsc_zca_zcd -Oz -o
/tmp/ccSxF1c0.s
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.

$ riscv64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-riscv64/bin/riscv64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-20260502093121-r17-273-g4188ac1ddb9ddd-checking-yes-rtl-df-extra-riscv64/bin/../libexec/gcc/riscv64-unknown-linux-gnu/17.0.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-isa-spec=2.2 --with-sysroot=/usr/riscv64-unknown-linux-gnu
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=riscv64-unknown-linux-gnu
--with-ld=/usr/bin/riscv64-unknown-linux-gnu-ld
--with-as=/usr/bin/riscv64-unknown-linux-gnu-as --disable-multilib
--enable-libsanitizer --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-20260502093121-r17-273-g4188ac1ddb9ddd-checking-yes-rtl-df-extra-riscv64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260502 (experimental) (GCC)

Reply via email to