Bug 52113 - [4.7 regression][lower-subreg.c] ICE: in extract_insn, at recog.c:2123
Summary: [4.7 regression][lower-subreg.c] ICE: in extract_insn, at recog.c:2123
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.7.0
: P3 major
Target Milestone: 4.7.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-02-03 17:35 UTC by Michal Hlavinka
Modified: 2012-02-04 12:58 UTC (History)
2 users (show)

See Also:
Host:
Target: avr
Build:
Known to work: 4.6.2
Known to fail:
Last reconfirmed: 2012-02-03 00:00:00


Attachments
gcc47-pr52113.patch (537 bytes, patch)
2012-02-04 00:10 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Hlavinka 2012-02-03 17:35:27 UTC
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)
Comment 1 Georg-Johann Lay 2012-02-03 18:47:10 UTC
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}
Comment 2 Jakub Jelinek 2012-02-04 00:10:04 UTC
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.
Comment 3 Georg-Johann Lay 2012-02-04 01:14:53 UTC
Thanks.

For the testcase, omit -mmcu=. That option is set by board.exp during testsuite:

-/* { dg-options "-O1" } */
+/* { dg-options "-O1 -mmcu=atmega64" } */
Comment 4 Jakub Jelinek 2012-02-04 07:39:14 UTC
Then it should be just a gcc.c-torture/compile/ test instead.
Comment 5 Jakub Jelinek 2012-02-04 12:47:58 UTC
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
Comment 6 Jakub Jelinek 2012-02-04 12:58:44 UTC
Fixed.