gcc 4.7 fails on code that was working in 4.6 without any problem Version: 4.7.0-20120128 Target: avr Problem happens only when optimization is used. Pre-processed reproducer: ============= cut ================= typedef unsigned int uint8_t __attribute__((__mode__(__QI__))); typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__))); typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__))); extern uint32_t inacCounter; uint8_t inactivityTimer; int main() { if(inacCounter>((uint32_t)inactivityTimer*1000)) inacCounter=0; } ============= cut ================= $ avr-g++ -c -mmcu=atmega64 reproducer.cpp -O1 reproducer.cpp: In function 'int main()': reproducer.cpp:11:1: error: unrecognizable insn: (insn 26 6 27 2 (set (concatn:HI [ (reg:QI 57) (reg:QI 58 [+1 ]) ]) (zero_extend:HI (reg:QI 48 [ inactivityTimer ]))) reproducer.cpp:10 -1 (nil)) reproducer.cpp:11:1: internal compiler error: in extract_insn, at recog.c:2123 Please submit a full bug report, with preprocessed source if appropriate. Additional information: $ avr-gcc -v Using built-in specs. COLLECT_GCC=avr-gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/avr/4.7.0/lto-wrapper Target: avr Configured with: ../gcc-4.7-20120128/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-system-zlib --enable-version-specific-runtime-libs --with-pkgversion='Fedora 4.7-2.fc16' --with-bugurl=https://bugzilla.redhat.com/ Thread model: single gcc version 4.7.0 20120128 (experimental) (Fedora 4.7-2.fc16)
The ICE happens in .split2 and can be avoided by -fno-split-wide-types The strange concatn insn 26 is generated in pass .subreg2 after .split1 generated the following sequence for the multiply: (insn 26 6 27 2 (set (reg:HI 55) (zero_extend:HI (reg:QI 48 [ inactivityTimer ]))) pr52113.cpp:10 -1 (nil)) (insn 27 26 29 2 (set (reg:HI 56) (const_int 1000 [0x3e8])) pr52113.cpp:10 -1 (nil)) (insn 29 27 30 2 (set (reg:HI 18 r18) (reg:HI 55)) pr52113.cpp:10 -1 (nil)) (insn 30 29 31 2 (set (reg:HI 26 r26) (reg:HI 56)) pr52113.cpp:10 -1 (nil)) (insn 31 30 32 2 (set (reg:SI 22 r22) (mult:SI (zero_extend:SI (reg:HI 18 r18)) (zero_extend:SI (reg:HI 26 r26)))) pr52113.cpp:10 -1 (nil)) (insn 32 31 9 2 (set (reg:SI 49) (reg:SI 22 r22)) pr52113.cpp:10 -1 (nil)) The sequence comes from .split1 that splitted the following pattern that was sythesized by combine: (insn 8 6 9 2 (parallel [ (set (reg:SI 49) (mult:SI (zero_extend:SI (reg:QI 48 [ inactivityTimer ])) (const_int 1000 [0x3e8]))) (clobber (reg:HI 26 r26)) (clobber (reg:DI 18 r18)) ]) pr52113.cpp:10 111 {muluqisi3}
Created attachment 26568 [details] gcc47-pr52113.patch Untested fix. The problem is that lower-subreg relies on recog_memoized being performed on all insns before changing decomposable regs into concatn, because otherwise they might not be recognized. They will be fixed up during the pass later on, but if they weren't recognized first, extract_insn will already ICE. Don't have time to test this for avr, will only include it in my next x86_64/i686 bootstrap/regtest.
Thanks. For the testcase, omit -mmcu=. That option is set by board.exp during testsuite: -/* { dg-options "-O1" } */ +/* { dg-options "-O1 -mmcu=atmega64" } */
Then it should be just a gcc.c-torture/compile/ test instead.
Author: jakub Date: Sat Feb 4 12:47:55 2012 New Revision: 183894 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183894 Log: PR rtl-optimization/52113 * lower-subreg.c (decompose_multiword_subregs): Call recog_memoized even for decomposable shift/zext insns. * gcc.target/avr/pr52113.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr52113.c Modified: trunk/gcc/ChangeLog trunk/gcc/lower-subreg.c trunk/gcc/testsuite/ChangeLog
Fixed.