Bug 28181

Summary: [4.2 regression] ICE in reload_cse_simplify_operands, at postreload.c:393 on m68k
Product: gcc Reporter: Martin Michlmayr <tbm>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: ccc94453, debian-gcc, gcc-bugs, pinskia, rsandifo, schwab, wouter
Priority: P5 Keywords: ice-on-valid-code
Version: 4.1.1   
Target Milestone: 4.3.0   
Host: Target: m68k-linux-gnu
Build: m68k-linux-gnu Known to work: 3.4.6 4.3.0
Known to fail: 4.0.4 4.1.1 4.2.0 4.2.5 Last reconfirmed:
Attachments: test case for 4.2
preprocessed source
preprocessed source
test case
testcase
Partial patch

Description Martin Michlmayr 2006-06-27 20:13:30 UTC
[ Forwarded from http://bugs.debian.org/375522 ]

I get the following ICE with gcc 4.1 and 4.2 on m68k:

928:tbm@reyes: ~] m68k-linux-gnu-gcc -c -O2 mini.c
mini.c: In function ‘scan’:
mini.c:48: warning: incompatible implicit declaration of built-in function ‘strlen’
mini.c:90: warning: assignment makes integer from pointer without a cast
mini.c:94: warning: incompatible implicit declaration of built-in function ‘strlen’
mini.c:115: warning: initialization from incompatible pointer type
mini.c:122: error: insn does not satisfy its constraints:
(insn 323 57 324 9 (set (reg:QI 8 %a0)
        (mem/s:QI (plus:SI (reg/f:SI 14 %a6)
                (const_int -128 [0xffffff80])) [0 name+0 S1 A16])) 41 {*m68k.md:748} (nil)
    (nil))
mini.c:122: internal compiler error: in reload_cse_simplify_operands, at postreload.c:393
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
zsh: exit 1     m68k-linux-gnu-gcc -c -O2 mini.c
929:tbm@reyes: ~] m68k-linux-gnu-gcc -c -O1 mini.c
mini.c: In function ‘scan’:
mini.c:48: warning: incompatible implicit declaration of built-in function ‘strlen’
mini.c:90: warning: assignment makes integer from pointer without a cast
mini.c:94: warning: incompatible implicit declaration of built-in function ‘strlen’
mini.c:115: warning: initialization from incompatible pointer type
930:tbm@reyes: ~]

FWIW, this test case fails with 4.2 but works with 4.1.  The original bug was reported against 4.1 though.  I can build a 4.1 and run delta again if this would be helpful.  The original ICE with 4.1 is:

crest% gcc -c -O2 scansbr.i
scansbr.c: In function 'scan':
scansbr.c:369: error: insn does not satisfy its constraints:
(insn 1657 689 1658 81 (set (reg:QI 8 %a0)
        (mem/s:QI (plus:SI (reg/f:SI 14 %a6)
                (const_int -212 [0xffffff2c])) [0 name+0 S1 A16])) 33 {*m68k.md:748} (nil)
    (nil))
scansbr.c:369: internal compiler error: in reload_cse_simplify_operands, at postreload.c:393
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.
Comment 1 Martin Michlmayr 2006-06-27 20:15:46 UTC
Update: 4.0 shows the same problem.  3.4.6 works

crest% gcc-4.0 -c -O2 scansbr.i
scansbr.c: In function 'scan':
scansbr.c:154: warning: pointer targets in passing argument 2 of 'm_getfld' differ in signedness
scansbr.c:154: warning: pointer targets in passing argument 3 of 'm_getfld' differ in signedness
scansbr.c:189: warning: pointer targets in passing argument 2 of 'm_getfld' differ in signedness
scansbr.c:189: warning: pointer targets in passing argument 3 of 'm_getfld' differ in signedness
scansbr.c:225: warning: pointer targets in passing argument 2 of 'm_getfld' differ in signedness
scansbr.c:225: warning: pointer targets in passing argument 3 of 'm_getfld' differ in signedness
scansbr.c:262: warning: pointer targets in passing argument 2 of 'm_getfld' differ in signedness
scansbr.c:262: warning: pointer targets in passing argument 3 of 'm_getfld' differ in signedness
scansbr.c:369: error: insn does not satisfy its constraints:
(insn 1692 701 1693 82 (set (reg:QI 8 %a0)
        (mem/s:QI (plus:SI (reg/f:SI 14 %a6)
                (const_int -212 [0xffffff2c])) [0 name+0 S1 A16])) 33 {*m68k.md:746} (nil)
    (nil))
scansbr.c:369: internal compiler error: in reload_cse_simplify_operands, at postreload.c:391
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see <URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.
Comment 2 Martin Michlmayr 2006-06-27 20:17:34 UTC
Created attachment 11762 [details]
test case for 4.2

reduced testcase, shows the problem with 4.2 only
Comment 3 Martin Michlmayr 2006-06-27 20:19:58 UTC
Created attachment 11763 [details]
preprocessed source

Original preprocessed source, shows the problem with 4.0, 4.1 and 4.2.  Works with 3.4.6.
Comment 4 Martin Michlmayr 2006-06-27 20:19:59 UTC
Created attachment 11764 [details]
preprocessed source

Original preprocessed source, shows the problem with 4.0, 4.1 and 4.2.  Works with 3.4.6.
Comment 5 Martin Michlmayr 2006-06-27 21:24:26 UTC
Created attachment 11765 [details]
test case

This one fails with gcc 4.1 and 4.2.
Comment 6 Andreas Schwab 2006-07-01 07:01:36 UTC
The bug is much older, I was able to get it fail using the sources at the 3.4 branch point.  That 3.4.6 does not fail is probably just coincidence.
Comment 7 Mark Mitchell 2006-07-17 02:53:06 UTC
m68k is not a primary or secondary platform.
Comment 8 Martin Michlmayr 2006-10-15 08:43:25 UTC
Created attachment 12436 [details]
testcase

another testcase
Comment 9 Rask Ingemann Lambertsen 2006-12-11 20:24:24 UTC
Created attachment 12785 [details]
Partial patch

Please try this patch. It removes the ICE, but the code may not run on 68000 and 68010 CPUs because there is also an alignment problem. Please see <URL:http://gcc.gnu.org/ml/gcc-patches/2006-12/msg00766.html> for details.
Comment 10 Gabriel Dos Reis 2007-02-03 17:43:20 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 11 rsandifo@gcc.gnu.org 2007-03-06 09:01:26 UTC
Subject: Bug 28181

Author: rsandifo
Date: Tue Mar  6 09:01:07 2007
New Revision: 122609

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122609
Log:
gcc/
	PR target/28181
	* config/m68k/m68k-protos.h (m68k_secondary_reload_class): Declare.
	(m68k_preferred_reload_class): Likewise.
	* config/m68k/m68k.h (HARD_REGNO_MODE_OK): Remove duplicated comment.
	(SECONDARY_RELOAD_CLASS): Define.
	(PREFERRED_RELOAD_CLASS): Use m68k_preferred_reload_class.
	(LIMIT_RELOAD_CLASS): Delete.
	* config/m68k/m68k.c (m68k_regno_mode_ok): Don't prevent address
	registers from storing bytes.
	(m68k_secondary_reload_class): New function.
	(m68k_preferred_reload_class): Likewise.

gcc/testsuite/
	* gcc.c-torture/compile/m68k-byte-addr.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/m68k-byte-addr.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/m68k/m68k-protos.h
    trunk/gcc/config/m68k/m68k.c
    trunk/gcc/config/m68k/m68k.h
    trunk/gcc/testsuite/ChangeLog

Comment 12 rsandifo@gcc.gnu.org 2007-03-06 09:02:55 UTC
Now fixed in trunk.  The patch may be too invasive to backport;
I'm not sure.
Comment 13 Joseph S. Myers 2008-07-04 21:25:28 UTC
Closing 4.1 branch.
Comment 14 Joseph S. Myers 2009-03-30 16:58:47 UTC
Closing 4.2 branch, fixed in 4.3.