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

            Bug ID: 108819
           Summary: ICE on valid code at -O1 with "-fno-tree-ccp
                    -fno-tree-forwprop" on x86_64-linux-gnu: tree check:
                    expected ssa_name, have integer_cst in
                    number_of_iterations_cltz, at
                    tree-ssa-loop-niter.cc:2394
           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: ---

It appears to be a recent regression. 

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

[570] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.1/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
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230216 (experimental) [master r13-6073-g441c466fd4d] (GCC)
[571] %
[571] % gcctk -O1 small.c; ./a.out
[572] %
[572] % gcctk -O1 -fno-tree-ccp -fno-tree-forwprop small.c
during GIMPLE pass: ivcanon
small.c: In function ‘main’:
small.c:2:5: internal compiler error: tree check: expected ssa_name, have
integer_cst in number_of_iterations_cltz, at tree-ssa-loop-niter.cc:2394
    2 | int main() {
      |     ^~~~
0x7a8f41 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../gcc-trunk/gcc/tree.cc:8909
0x78196d tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../../gcc-trunk/gcc/tree.h:3530
0x78196d number_of_iterations_cltz
        ../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:2394
0x10838e2 number_of_iterations_exit_assumptions(loop*, edge_def*,
tree_niter_desc*, gcond**, bool, basic_block_def**)
        ../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:3287
0x10838e2 number_of_iterations_exit(loop*, edge_def*, tree_niter_desc*, bool,
bool, basic_block_def**)
        ../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:3274
0x1083e08 estimate_numbers_of_iterations(loop*)
        ../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:4844
0x1086685 estimate_numbers_of_iterations(function*)
        ../../gcc-trunk/gcc/tree-ssa-loop-niter.cc:5072
0x105aad6 canonicalize_induction_variables()
        ../../gcc-trunk/gcc/tree-ssa-loop-ivcanon.cc:1293
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.
[573] %
[573] % cat small.c
int a, b;
int main() {
  int d = 1;
  for (; b; b++)
    if (a < 1)
      while (d <= a && a <= 0UL) {
        int *e = &d;
        *e = 0;
      }
  return 0;
}

Reply via email to