Bug 53701

Summary: ICE on ia64 (when building Allegro 4.4) in sel-sched
Product: gcc Reporter: Tobias Hansen <tobias.han>
Component: rtl-optimizationAssignee: Andrey Belevantsev <abel>
Status: RESOLVED FIXED    
Severity: normal CC: abel, mikpelinux
Priority: P3 Keywords: ice-on-valid-code
Version: 4.6.3   
Target Milestone: ---   
Host: ia64 Target: ia64-*-linux
Build: Known to work: 4.7.0
Known to fail: 4.8.0 Last reconfirmed: 2012-08-06 00:00:00
Attachments: preprocessed source
proposed patch

Description Tobias Hansen 2012-06-16 23:53:34 UTC
Created attachment 27636 [details]
preprocessed source

We encounter an ICE on ia64 when building Allegro 4.4 on Debian unstable with gcc-4.6 4.6.3-6. It builds fine on all other architectures. Here is the command line and output, the preprocessed source is attached.

| [  1%] Building C object CMakeFiles/allegro.dir/src/c/cgfx15.c.o
| /usr/bin/gcc  -Dallegro_EXPORTS -g -O2 -Wformat -Werror=format-security  -W -Wall -Wno-unused-parameter -Wdeclaration-after-statement -O3 -DNDEBUG -fPIC -I/home/kibi/allegro4.4-4.4.2/include -I/home/kibi/allegro4.4-4.4.2/build/include -isystem /usr/include/alsa    -DALLEGRO_SRC -DALLEGRO_MODULES_PATH='"/usr/lib/ia64-linux-gnu/allegro/4.4.2"' -o CMakeFiles/allegro.dir/src/c/cgfx15.c.o   -c /home/kibi/allegro4.4-4.4.2/src/c/cgfx15.c
| In file included from /home/kibi/allegro4.4-4.4.2/src/c/cgfx15.c:25:0:
| /home/kibi/allegro4.4-4.4.2/src/c/cgfx.h: In function '_linear_hline15':
| /home/kibi/allegro4.4-4.4.2/src/c/cgfx.h:217:1: internal compiler error: in find_used_regs, at sel-sched.c:3273
| Please submit a full bug report,
| with preprocessed source if appropriate.
| See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
| Preprocessed source stored into /tmp/ccFa4uiC.out file, please attach this to your bugreport.
Comment 2 Cyril Brulebois 2012-06-17 09:47:22 UTC
FWIW, it builds fine with: gcc-4.7 (Debian 4.7.1-1) 4.7.0
Comment 3 Mikael Pettersson 2012-06-17 10:36:36 UTC
ICEs gcc 4.6.3 and 4.4.7, compiles w/o error with 4.7.1, 4.5.3, 4.3.6, and 4.2.4 (all crosses to ia64-linux hosted on i686-linux).
Comment 4 Mikael Pettersson 2012-06-17 14:34:44 UTC
This was fixed for gcc-4.7.0 by r177658:
http://gcc.gnu.org/ml/gcc-cvs/2011-08/msg00672.html
http://gcc.gnu.org/ml/gcc-patches/2011-08/msg00353.html

The patch applies cleanly to 4.6.3 and cures the ICE on this test case.  I haven't tested the backport beyond that.

For 4.6.3 you can also avoid the ICE by reducing the optimization level to -O2.
Comment 5 Mikael Pettersson 2012-07-27 07:14:20 UTC
Unfortunately r177658 seems to be the cause of wrong-code PR53975.
Comment 6 Andrey Belevantsev 2012-08-06 14:21:52 UTC
The trunk (with PR53975 fixed and thus the old patch reverted) ICEs in av_set_could_be_blocked_by_bookkeeping_p, I will take a look.
Comment 7 Andrey Belevantsev 2012-08-08 11:26:01 UTC
Created attachment 27959 [details]
proposed patch

The problem is that when checking expressions that are blocked for movement because of recently created bookkeeping code we need to consider also all old forms of those expressions as they could get transformed on the way up.  PR53975 just uncovers this bug but is actually unrelated.

The attached patch fixes the testcase but is not yet otherwise tested.
Comment 8 Andrey Belevantsev 2012-08-09 14:08:38 UTC
Author: abel
Date: Thu Aug  9 14:08:31 2012
New Revision: 190253

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190253
Log:

    PR rtl-optimization/53701
    * sel-sched.c (vinsn_vec_has_expr_p): Clarify function comment.
    Process not only expr's vinsns but all old vinsns from expr's
    history of changes.
    (update_and_record_unavailable_insns): Clarify comment.

    * gcc.dg/pr53701.c: New test. 

Added:
    trunk/gcc/testsuite/gcc.dg/pr53701.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/sel-sched.c
    trunk/gcc/testsuite/ChangeLog
Comment 9 Andrey Belevantsev 2012-10-16 13:22:26 UTC
Author: abel
Date: Tue Oct 16 13:22:22 2012
New Revision: 192498

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192498
Log:
2012-10-16  Andrey Belevantsev  <abel@ispras.ru>

    Backport from mainline
    2012-08-09  Andrey Belevantsev  <abel@ispras.ru>

    PR rtl-optimization/53701
    * sel-sched.c (vinsn_vec_has_expr_p): Clarify function comment.
    Process not only expr's vinsns but all old vinsns from expr's
    history of changes.
    (update_and_record_unavailable_insns): Clarify comment.   

testsuite:
2012-10-16  Andrey Belevantsev  <abel@ispras.ru>

    Backport from mainline
    2012-08-09  Andrey Belevantsev  <abel@ispras.ru>

    PR rtl-optimization/53701
    * gcc.dg/pr53701.c: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/pr53701.c
Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/sel-sched.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 10 Andrey Belevantsev 2012-10-22 19:34:41 UTC
Author: abel
Date: Mon Oct 22 19:34:35 2012
New Revision: 192693

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192693
Log:
        Backport from mainline
        2012-08-09  Andrey Belevantsev  <abel@ispras.ru>

        PR rtl-optimization/53701
        * sel-sched.c (vinsn_vec_has_expr_p): Clarify function comment.
        Process not only expr's vinsns but all old vinsns from expr's
        history of changes.

        * gcc.dg/pr53701.c: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/pr53701.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/sel-sched.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 11 Andrey Belevantsev 2012-10-22 19:40:17 UTC
Fixed.