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

            Bug ID: 105753
           Summary: [avr] ICE: in add_clobbers, at
                    config/avr/avr-dimode.md:2705
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: filip.hejsek at gmail dot com
  Target Milestone: ---
            Target: avr

GCC fails when compiling the following C program for AVR (with at least -O1):

int digit_sum(unsigned long n) {
  int sum = 0;

  do {
    int x = n % 10;
    n /= 10;
    sum += x;
  } while(n);

  return sum;
}

I have tested both GCC 12.1.0 form Arch Linux and a development version (GCC
13.0.0) compiled from git sources.

Here is the compiler output:

$ ~/avr_gcc_install/bin/avr-gcc -c -O1 bug.c
during RTL pass: combine
bug.c: In function ‘digit_sum’:
bug.c:13:1: internal compiler error: in add_clobbers, at
config/avr/avr-dimode.md:2705
   13 | }
      | ^
0x770d30 add_clobbers(rtx_def*, int)
        ../../gcc/gcc/config/avr/avr-dimode.md:2705
0x1645c94 recog_for_combine_1
        ../../gcc/gcc/combine.cc:11422
0x164979e recog_for_combine
        ../../gcc/gcc/combine.cc:11622
0x165aef7 try_combine
        ../../gcc/gcc/combine.cc:3543
0x165e72f combine_instructions
        ../../gcc/gcc/combine.cc:1266
0x165e72f rest_of_handle_combine
        ../../gcc/gcc/combine.cc:14976
0x165e72f execute
        ../../gcc/gcc/combine.cc:15021
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.
$ ~/avr_gcc_install/bin/avr-gcc -v
Using built-in specs.
Reading specs from
/home/filiph/avr_gcc_install/lib/gcc/avr/13.0.0/device-specs/specs-avr2
COLLECT_GCC=/home/filiph/avr_gcc_install/bin/avr-gcc
COLLECT_LTO_WRAPPER=/home/filiph/avr_gcc_install/libexec/gcc/avr/13.0.0/lto-wrapper
Target: avr
Configured with: ../gcc/configure --prefix=/home/filiph/avr_gcc_install
--target=avr --enable-languages=c --with-as=/usr/bin/avr-as --with-gnu-as
--with-ld=/usr/bin/avr-ld --with-gnu-ld
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20220525 (experimental) [master -gda2c56ee6] (GCC) 

$ avr-gcc -c -O1 bug.c
during RTL pass: combine
bug.c: In function 'digit_sum':
bug.c:13:1: internal compiler error: in add_clobbers, at
config/avr/avr-dimode.md:2705
   13 | }
      | ^
0x140115b diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char
const*, __va_list_tag (*) [1], diagnostic_t)
        ???:0
0x140209d internal_error(char const*, ...)
        ???:0
0x5bafbc fancy_abort(char const*, int, char const*)
        ???:0
0x5b1839 add_clobbers(rtx_def*, int) [clone .cold]
        ???:0
0x1213b97 recog_for_combine_1(rtx_def**, rtx_insn*, rtx_def**)
        ???:0
0x1215e8e recog_for_combine(rtx_def**, rtx_insn*, rtx_def**)
        ???:0
0x1228da5 try_combine(rtx_insn*, rtx_insn*, rtx_insn*, rtx_insn*, int*,
rtx_insn*)
        ???:0
0x122c0a4 (anonymous namespace)::pass_combine::execute(function*)
        ???:0
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.
$ avr-gcc -v
Using built-in specs.
Reading specs from /usr/lib/gcc/avr/12.1.0/device-specs/specs-avr2
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/12.1.0/lto-wrapper
Target: avr
Configured with: /build/avr-gcc/src/gcc-12.1.0/configure
--disable-install-libiberty --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-linker-build-id --disable-nls
--disable-werror --disable-__cxa_atexit --enable-checking=release
--enable-clocale=gnu --enable-gnu-unique-object --enable-gold
--enable-languages=c,c++ --enable-ld=default --enable-lto --enable-plugin
--enable-shared --infodir=/usr/share/info --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --prefix=/usr --target=avr
--with-as=/usr/bin/avr-as --with-gnu-as --with-gnu-ld --with-ld=/usr/bin/avr-ld
--with-plugin-ld=ld.gold --with-system-zlib --with-isl
--enable-gnu-indirect-function
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (GCC) 

(This bug seems to be similar to bug 88051, but that one was on i386.)

Reply via email to