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

            Bug ID: 121295
           Summary: ICE on valid code at -O{2,3} with "-fno-tree-copy-prop
                    -fno-tree-pre -fno-code-hoisting": Segmentation fault
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/GehEvoncf

It appears to be a recent regression as it doesn't reproduce with 15.1 and
earlier. 


[614] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250729 (experimental) (GCC) 
[615] % 
[615] % gcctk -O3 -fno-tree-copy-prop -fno-tree-pre -fno-code-hoisting small.c
during GIMPLE pass: ifcvt
small.c: In function ‘main’:
small.c:2:5: internal compiler error: Segmentation fault
    2 | int main() {
      |     ^~~~
0x2540216 internal_error(char const*, ...)
        ../../gcc-trunk/gcc/diagnostic-global-context.cc:534
0x11a2ea3 crash_signal
        ../../gcc-trunk/gcc/toplev.cc:323
0x7efe2400951f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xda39c4 gimple_code(gimple const*)
        ../../gcc-trunk/gcc/gimple.h:1845
0xda39c4 gimple_get_lhs(gimple const*)
        ../../gcc-trunk/gcc/gimple.cc:2005
0xdcf66f gimple_range_type(gimple const*)
        ../../gcc-trunk/gcc/gimple-range-fold.h:62
0xdcf66f gimple_stmt_nonnegative_warnv_p(gimple*, bool*, int)
        ../../gcc-trunk/gcc/gimple-fold.cc:11158
0xdcf999 gimple_phi_nonnegative_warnv_p
        ../../gcc-trunk/gcc/gimple-fold.cc:11143
0xdcf999 gimple_stmt_nonnegative_warnv_p(gimple*, bool*, int)
        ../../gcc-trunk/gcc/gimple-fold.cc:11176
0xd422f1 tree_binary_nonnegative_warnv_p(tree_code, tree_node*, tree_node*,
tree_node*, bool*, int)
        ../../gcc-trunk/gcc/fold-const.cc:14889
0xd422f1 tree_binary_nonnegative_warnv_p(tree_code, tree_node*, tree_node*,
tree_node*, bool*, int)
        ../../gcc-trunk/gcc/fold-const.cc:14796
0xd432f8 tree_expr_nonnegative_warnv_p(tree_node*, bool*, int)
        ../../gcc-trunk/gcc/tree.h:4748
0xd432f8 tree_expr_nonnegative_p(tree_node*)
        ../../gcc-trunk/gcc/fold-const.cc:15294
0x179681f gimple_simplify_COND_EXPR(gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), code_helper, tree_node*, tree_node*, tree_node*, tree_node*)
        /local/suz-local/software/gccbuild/objdir/gcc/gimple-match-2.cc:52470
0x1aae28e gimple_resimplify3
        ../../gcc-trunk/gcc/gimple-match-exports.cc:1096
0x121a0ac fold_build_cond_expr
        ../../gcc-trunk/gcc/tree-if-conv.cc:515
0x1220d35 fold_build_cond_expr
        ../../gcc-trunk/gcc/tree-if-conv.cc:498
0x1220d35 predicate_scalar_phi
        ../../gcc-trunk/gcc/tree-if-conv.cc:2504
0x1221cc1 predicate_all_scalar_phis
        ../../gcc-trunk/gcc/tree-if-conv.cc:2655
0x1221cc1 combine_blocks
        ../../gcc-trunk/gcc/tree-if-conv.cc:3228
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.
[616] % 
[616] % cat small.c
int a, b, c;
int main() {
  int *d = &a;
  while (b)
    b = (*d &= 10) <= 0 || (*d = c);
  return 0;
}

Reply via email to