Bug 34762 - [4.2 regression] internal compiler error: in delete_output_reload, at reload1.c:7958
Summary: [4.2 regression] internal compiler error: in delete_output_reload, at reload1...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-12 20:52 UTC by Randolph Chung
Modified: 2008-02-23 21:24 UTC (History)
2 users (show)

See Also:
Host: hppa-linux
Target: hppa-linux
Build: hppa-linux
Known to work: 3.4.6 4.1.3
Known to fail: 4.2.1
Last reconfirmed:


Attachments
Testcase (48.47 KB, application/x-gzip)
2008-01-12 20:54 UTC, Randolph Chung
Details
reload.c.d (251 bytes, text/plain)
2008-01-13 02:52 UTC, dave
Details
More complete fix for reload.c (777 bytes, patch)
2008-02-23 21:24 UTC, Michael Eager
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Randolph Chung 2008-01-12 20:52:28 UTC
While building RPM on hppa with gcc-4.2, build fails with the captioned error. Somewhat reduced testcase attached.

Builds fine with -O1 or without -fPIC, or with older compilers.

ffmpeg and squashfs also fail to build with a similar error (not always built with  -fPIC)
Comment 1 Randolph Chung 2008-01-12 20:54:01 UTC
Created attachment 14931 [details]
Testcase
Comment 2 Richard Biener 2008-01-12 21:44:39 UTC
Probably a dup of PR32889.
Comment 3 dave 2008-01-13 01:46:11 UTC
Subject: Re:  [4.2 regression] internal compiler error: in delete_output_reload, at reload1.c:7958

> Probably a dup of PR32889.

Agreed but the current 4.2 branch still ICEs.  The failure doesn't
occur with 4.3.

I'm having difficulty understanding why this was classified as target
bug.  It appears to me to be a middle-end (reload) bug.

Before the ICE, we handle a very similar reload:

Starting program: /home/dave/gcc-4.2/objdir/stage1-gcc/cc1 -fpreprocessed pr34762.i -dumpbase pr34762.i -auxbase pr34762 -O2 -version -o pr34762.s -fPIC
GNU C version 4.2.3 20080106 (prerelease) (hppa-linux)
        compiled by GNU C version 4.1.0.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
options passed:  -fpreprocessed -auxbase -O2 -fPIC
options enabled:  -fPIC -falign-loops -fargument-alias -fbranch-count-reg
 -fcaller-saves -fcommon -fcprop-registers -fcrossjumping
 -fcse-follow-jumps -fcse-skip-blocks -fdefer-pop -fdelayed-branch
 -fdelete-null-pointer-checks -fearly-inlining
 -feliminate-unused-debug-types -fexpensive-optimizations -ffunction-cse
 -fgcse -fgcse-lm -fguess-branch-probability -fident -fif-conversion
 -fif-conversion2 -finline-functions-called-once -fipa-pure-const
 -fipa-reference -fipa-type-escape -fivopts -fkeep-static-consts
 -fleading-underscore -fmath-errno -fmerge-constants -fmove-loop-invariants
 -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls
 -fpeephole -fpeephole2 -freg-struct-return -fregmove -freorder-blocks
 -freorder-functions -frerun-cse-after-loop -fsched-interblock -fsched-spec
 -fsched-stalled-insns-dep -fschedule-insns -fschedule-insns2 -fshow-column
 -fsplit-ivs-in-unroller -fstrict-aliasing -fstrict-overflow -fthread-jumps
 -ftoplevel-reorder -ftrapping-math -ftree-ccp -ftree-ch -ftree-copy-prop
 -ftree-copyrename -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-fre
 -ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize -ftree-lrs
 -ftree-pre -ftree-salias -ftree-sink -ftree-sra -ftree-store-ccp
 -ftree-store-copy-prop -ftree-ter -ftree-vect-loop-version -ftree-vrp
 -funit-at-a-time -fvar-tracking -fzero-initialized-in-bss -mbig-switch
 -mgas -mglibc -mno-space-regs
Compiler executable checksum: 7052689d04078c8c580b43f74ef2f4ae
gnu_dev_major gnu_dev_minor gnu_dev_makedev stat lstat fstat fstatat mknod mknodat stat64 lstat64 fstat64 fstatat64 vprintf getchar fgetc_unlocked getc_unlocked getchar_unlocked putchar fputc_unlocked putc_unlocked putchar_unlocked getline feof_unlocked ferror_unlocked __strcspn_c1 __strcspn_c2 __strcspn_c3 __strspn_c1 __strspn_c2 __strspn_c3 __strpbrk_c2 __strpbrk_c3 __strtok_r_1c __strsep_1c __strsep_2c __strsep_3c strtod strtol strtoul strtof strtold strtoq strtouq strtoll strtoull atof atoi atol atoll tolower toupper __sigismember __sigaddset __sigdelset __cmsg_nxthdr xislower xisupper xisalpha xisdigit xisalnum xisblank xisspace xtolower xtoupper headerFreeData h2hv headerNew headerFree headerLink headerUnlink headerSort headerUnsort headerSizeof headerUnload headerReload headerCopy headerLoad headerCopyLoad headerRead headerWrite headerIsEntry headerFreeTag headerGetEntry headerGetEntryMinMemory headerAddEntry headerAppendEntry headerAddOrAppendEntry headerAddI18NStrin!
 g headerModifyEntry headerRemoveEntry headerSprintf headerCopyTags headerFreeIterator headerInitIterator headerNextIterator _free tag2sln runLuaScript runScript runInstScript start
Analyzing compilation unitPerforming interprocedural optimizations
Assembling functions:
tag2sln headerFreeData runInstScript
Breakpoint 1, emit_move_sequence (operands=0xfb6c74cc, mode=SImode,
    scratch_reg=0x0) at ../../gcc/gcc/config/pa/pa.c:1332
1332      register rtx operand0 = operands[0];
(gdb) p debug_rtx (operands[0])
(reg:SI 21 %r21)
$18 = void
(gdb) p debug_rtx (operands[1])
(const_int 8252 [0x203c])
$19 = void
(gdb) bt
#0  emit_move_sequence (operands=0xfb6c74cc, mode=SImode, scratch_reg=0x0)
    at ../../gcc/gcc/config/pa/pa.c:1332
#1  0x0052d0e4 in gen_movsi (operand0=0x403bed70, operand1=0x403b67a0)
    at ../../gcc/gcc/config/pa/pa.md:2430
#2  0x003f1354 in emit_move_insn_1 (x=0x403bed70, y=0x403b67a0)
    at ../../gcc/gcc/expr.c:3225
#3  0x0057a2d4 in gen_move_insn (x=0x403bed70, y=0x403b67a0)
    at ../../gcc/gcc/optabs.c:4399
#4  0x006096d8 in gen_reload (out=0x403bed70, in=0x403b67a0, opnum=0,
    type=RELOAD_FOR_OUTPUT_ADDRESS) at ../../gcc/gcc/reload1.c:7839
#5  0x0060934c in gen_reload (out=0x403bed70, in=0x403bed40, opnum=0,
    type=RELOAD_FOR_OUTPUT_ADDRESS) at ../../gcc/gcc/reload1.c:7746
#6  0x006055ac in emit_input_reload_insns (chain=0xadfdf8, rl=0xa3b00c,
    old=0x403bed40, j=0) at ../../gcc/gcc/reload1.c:6798
#7  0x006064d8 in do_input_reload (chain=0xadfdf8, rl=0xa3b00c, j=0)
    at ../../gcc/gcc/reload1.c:7055
#8  0x00606fdc in emit_reload_insns (chain=0xadfdf8)
    at ../../gcc/gcc/reload1.c:7228
...
(gdb) c
Continuing

Breakpoint 2, delete_output_reload (insn=0x403a6f28, j=1, last_reload_reg=5)
    at ../../gcc/gcc/reload1.c:7932
7932          gcc_assert (!rtx_equal_p (XEXP (i1, 0), substed));
(gdb) p debug_rtx (insn)
(insn 314 313 315 25 (set (mem/c:SI (plus:SI (reg/f:SI 3 %r3)
                (const_int 8256 [0x2040])) [89 freePrefixes+0 S4 A32])
	(const_int 0 [0x0])) 37 {*pa.md:2484} (nil)
    (nil))
$22 = void
(gdb) p debug_rtx (substed)
(mem/c:SI (plus:SI (reg/f:SI 3 %r3)
	(const_int 8256 [0x2040])) [89 freePrefixes+0 S4 A32])
$23 = void
(gdb) p debug_rtx (i1)
(expr_list:REG_EQUIV (mem/c:SI (plus:SI (reg/f:SI 3 %r3)
	    (const_int 8256 [0x2040])) [89 freePrefixes+0 S4 A32])
    (nil))
$24 = void

The backend doesn't generate REG_EQUIV notes.

From pr34762.i.138r.greg, the first reload is

Reloads for insn # 307
Reload 0: reload_in (SI) = (plus:SI (reg/f:SI 3 %r3)
                                                    (const_int 8256 [0x2040]))
        GENERAL_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 0), can't combine
	reload_in_reg: (plus:SI (reg/f:SI 3 %r3)
						    (const_int 8256 [0x2040]))
	reload_reg_rtx: (reg:SI 20 %r20)
Reload 1: reload_out (SI) = (mem/c:SI (plus:SI (reg/f:SI 3 %r3)
						    (const_int 8256 [0x2040] )) [89 freePrefixes+0 S4 A32])
	NO_REGS, RELOAD_FOR_OUTPUT (opnum = 0), optional
	reload_out_reg: (reg/v:SI 208 [ freePrefixes ])

Then, we fail with with this one

Reloads for insn # 314
Reload 0: reload_in (SI) = (plus:SI (reg/f:SI 3 %r3)
                                                    (const_int 8256 [0x2040]))
	GENERAL_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 0), can't combine
	reload_in_reg: (plus:SI (reg/f:SI 3 %r3)
						    (const_int 8256 [0x2040]))
	reload_reg_rtx: (reg:SI 21 %r21)
Reload 1: reload_out (SI) = (mem/c:SI (plus:SI (reg/f:SI 3 %r3)
						    (const_int 8256 [0x2040] )) [89 freePrefixes+0 S4 A32])
	NO_REGS, RELOAD_FOR_OUTPUT (opnum = 0), optional
	reload_out_reg: (reg/v:SI 208 [ freePrefixes ])

Dave
Comment 4 dave 2008-01-13 01:52:09 UTC
Subject: Re:  [4.2 regression] internal compiler error: in delete_output_reload, at reload1.c:7958

These are insns 307 and 314 from the greg pass.

> Reloads for insn # 307

(insn 307 280 281 24 (set (reg/v:SI 208 [ freePrefixes ])
        (reg:SI 264)) 37 {*pa.md:2484} (nil)
    (nil))

> Reloads for insn # 314

(insn 314 313 315 25 (set (reg/v:SI 208 [ freePrefixes ])
        (const_int 0 [0x0])) 37 {*pa.md:2484} (nil)
    (nil))

Dave
Comment 5 John David Anglin 2008-01-13 02:21:50 UTC
Appears to me to be a reload bug.
Comment 6 dave 2008-01-13 02:52:09 UTC
Subject: Re:  [4.2 regression] internal compiler
	error: in delete_output_reload, at reload1.c:7958

> Appears to me to be a reload bug.

This is totally untested but I believe the attached patch will fix
this bug.

Dave
Comment 7 dave 2008-01-13 02:52:09 UTC
Created attachment 14934 [details]
reload.c.d
Comment 8 John David Anglin 2008-01-13 16:53:46 UTC
Subject: Bug 34762

Author: danglin
Date: Sun Jan 13 16:53:02 2008
New Revision: 131508

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131508
Log:
	PR middle-end/34762
	* reload.c (find_reloads_toplev): Use rtx_equal_p to compare x and mem.


Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/reload.c

Comment 9 John David Anglin 2008-01-13 16:55:20 UTC
Fixed by patch.
Comment 10 Michael Eager 2008-02-23 21:24:25 UTC
Created attachment 15216 [details]
More complete fix for reload.c

This is a more complete patch to reload.c.
Duplicate of fix for bug 32889.