Bug 18421 - ICE in reload_cse_simplify_operands, at postreload.c:391
Summary: ICE in reload_cse_simplify_operands, at postreload.c:391
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.3
: P2 normal
Target Milestone: 3.4.5
Assignee: Bernardo Innocenti
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-11-10 18:26 UTC by Bernhard Walle
Modified: 2005-07-26 20:33 UTC (History)
4 users (show)

See Also:
Host:
Target: m68k-elf
Build:
Known to work: 3.4.5 4.0.2 4.1.0
Known to fail: 3.4.3 3.4.4 4.0.0
Last reconfirmed: 2005-04-07 08:27:29


Attachments
Preprocessed file which causes the error. (801 bytes, text/plain)
2004-11-12 07:50 UTC, Bernhard Walle
Details
Patch to prevent bytes from being loaded into address registers (1.50 KB, patch)
2005-04-10 14:00 UTC, Peter Barada
Details | Diff
Updated patch (2.07 KB, patch)
2005-07-11 23:23 UTC, Bernardo Innocenti
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Walle 2004-11-10 18:26:30 UTC
Hello,

I tried to compile the newlib with -O1. I got

m68k-elf-gcc
-B/home/bwalle/src/packages/BUILD/newlib-1.12.0/m68k-elf/m5307/newlib/ -isystem
/home/bwalle/src/packages/BUILD/newlib-1.12.0/m68k-elf/m5307/newlib/targ-include
-isystem /home/bwalle/src/packages/BUILD/newlib-1.12.0/newlib/libc/include 
-m5307 -DPACKAGE=\"newlib\" -DVERSION=\"1.12.0\"  -I.
-I../../../../.././newlib/libc/locale  -O2 -DCOMPACT_CTYPE
-DMISSING_SYSCALL_NAMES -fno-builtin    -O2 -O1  -O2 -O1  -m5307 -c
../../../../.././newlib/libc/locale/fix_grouping.c
../../../../.././newlib/libc/locale/fix_grouping.c: In function
`__fix_locale_grouping_str':
../../../../.././newlib/libc/locale/fix_grouping.c:82: Fehler: Befehl erfüllt
nicht seine Bedingungen:
(insn 217 106 107 12 (set (reg:QI 13 %a5)
        (mem:QI (reg/v/f:SI 9 %a1 [orig:32 src ] [32]) [0 S1 A8])) 33
{*m68k.md:826} (nil)
    (nil))
../../../../.././newlib/libc/locale/fix_grouping.c:82: interner Compiler-Fehler:
in reload_cse_simplify_operands, bei postreload.c:391
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

It's newlib 1.12.0, so you should have the source. There are no errors with
default -O2 or -O0.
Comment 1 Andrew Pinski 2004-11-12 02:52:03 UTC
Can you attach the preprocessed source?

Read http://gcc.gnu.org/bugs.html for more information on how to do this.
Comment 2 Bernhard Walle 2004-11-12 07:50:54 UTC
Created attachment 7526 [details]
Preprocessed file which causes the error.

Here it is.
Comment 3 Andrew Pinski 2004-11-13 06:01:58 UTC
Closing as invalid to ...
Comment 4 Andrew Pinski 2004-11-13 06:02:33 UTC
Reopen it.
Comment 5 Bernhard Walle 2004-11-13 10:47:50 UTC
What does this mean? You cannot reproduce this?

I configured gcc 3.4.3 with

./configure                                     \
        --prefix=%{prefix}                      \
        --target=m68k-elf                       \
        --program-prefix=m68k-elf-              \
        --mandir=%{prefix}/share/man            \
        --infodir=%{prefix}/share/info          \
        --enable-languages=c                    \
        --with-gnu-as                           \
        --with-gnu-ld                           \
        --disable-shared
Comment 6 Andrew Pinski 2004-11-13 15:57:33 UTC
No just bugzilla has no way to go from waiting to unconfirmed, I just have not have time to try to 
reproduce and reduce it yet.  Maybe someone else will.
Comment 7 Serge Belyshev 2004-11-14 13:53:05 UTC
// small testcase, use -O1 -m5200:

extern char n;
void foo (char *s)
{
  n += *s + 9;
}
Comment 8 arend.bayer@web.de 2005-01-08 21:40:30 UTC
I get an ICE at exactly the same place when trying to bootstrap current HEAD:  
xgcc --version  
Using built-in specs.  
Configured with: ../gcc/configure --prefix=/usr/local/gcc-head/  
--enable-languages=c,java  
Thread model: posix  
xgcc (GCC) 4.0.0 20050108 (experimental)  
  
The ICE happens when compiling libjava:  
(...)  
../../../gcc/libjava/java/lang/natDouble.cc: In static member function 'static  
jdouble java::lang::Double::longBitsToDouble(jlong)':  
../../../gcc/libjava/java/lang/natDouble.cc:62: error: insn does not satisfy  
its constraints:  
(insn 32 30 33 0 ../../../gcc/libjava/java/lang/natDouble.cc:61 (set (mem:DF  
(plus:SI (reg/f:SI 6 bp)  
                (const_int -24 [0xffffffe8])) [0 S8 A8])  
        (reg:DF 21 xmm0)) 65 {*movdf_nointeger} (nil)  
    (nil))  
../../../gcc/libjava/java/lang/natDouble.cc:62: internal compiler error: in  
reload_cse_simplify_operands, at postreload.c:391  
Please submit a full bug report.  
  
This is on SuSE linux 9.1, Bootstrap compiler is gcc 3.3.3 (as shipped by  
SuSE), and I use "-g -O2 -march=pentium3" as CFLAGS. (On a Pentium M.) Is this 
related, or should I open a new bug report? 
Comment 9 Joel Sherrill 2005-04-06 18:29:51 UTC
I can confirm this for m68k-rtems with gcc 4.0.0 20050303.  This looks like the
ICE that happens for us in our pppd stack on the Coldfire.   

I also confirm that the small test case in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18421#c7 occurs.

Comment 10 Ralf Corsepius 2005-04-07 08:26:44 UTC
I can reproduce it with gcc-4.0.0 (20050406)

Interestingly, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18421#c7
does not ICE with -mO0, -mO2, -mO3!
Comment 11 Peter Barada 2005-04-10 14:00:22 UTC
Created attachment 8577 [details]
Patch to prevent bytes from being loaded into address registers

The above patch fixes this problem by adding m68k_regno_mode_ok() which rejects
bytes in address registers.  I also had to modify addsi3_5200 to reject 's' in
favor of 'i' due to the 9 being pushed into a register(sice it is a known
value, it doesn't match any of the constraints(as in 's') in addsi3_5200).  I
haven't tried adding a peephole2 as suggested by Ian in:
http://gcc.gnu.org/ml/gcc/2004-04/msg01258.html

Also there's a ChangeLog entry at the beginning of the patch.
Comment 12 Ralf Corsepius 2005-04-11 14:00:26 UTC
(In reply to comment #11)
> Created an attachment (id=8577)
> Patch to prevent bytes from being loaded into address registers

I can confirm that today's m68k-rtems47-gcc-4.0 with your patch applied does not
ICE anymore, neither with the test case form comment #7, nor with rtems pppd code.
 
Comment 13 Andreas Schwab 2005-07-06 19:42:57 UTC
The patch in comment #11 is wrong. The condition (!((regno) < 8 && (regno) + 
GET_MODE_SIZE (mode) / 4 > 8)) is always true when regno >= 8.  It needs to be 
moved up to under the first condition. 
Comment 14 Bernardo Innocenti 2005-07-11 21:07:41 UTC
A revised patch was posted here:

  http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00853.html

I will attach it here in case someone wants to apply it
to an old version of GCC.
Comment 15 Bernardo Innocenti 2005-07-11 23:23:53 UTC
Created attachment 9246 [details]
Updated patch
Comment 16 CVS Commits 2005-07-11 23:32:11 UTC
Subject: Bug 18421

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	bernie@gcc.gnu.org	2005-07-11 23:32:01

Modified files:
	gcc            : ChangeLog 
	gcc/config/m68k: m68k.md m68k.c m68k.h m68k-protos.h 

Log message:
	PR middle-end/16719
	PR middle-end/18421
	* config/m68k/m68k.h (HARD_REGNO_MODE_OK): Disallow bytes
	in address registers.
	* config/m68k/m68k.c (hard_regno_mode_ok): Likewise.
	* config/m68k/m68k.md: Replace 's' with 'i' in 4th
	alternative of addsi3_5200.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9411&r2=2.9412
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k.md.diff?cvsroot=gcc&r1=1.84&r2=1.85
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k.c.diff?cvsroot=gcc&r1=1.152&r2=1.153
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k.h.diff?cvsroot=gcc&r1=1.128&r2=1.129
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k-protos.h.diff?cvsroot=gcc&r1=1.20&r2=1.21

Comment 17 Bernardo Innocenti 2005-07-11 23:33:52 UTC
Fixed.
Comment 18 Bernardo Innocenti 2005-07-11 23:35:07 UTC
Oops... still pending for 4.0 and 3.4.
Comment 19 CVS Commits 2005-07-26 04:40:52 UTC
Subject: Bug 18421

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	bernie@gcc.gnu.org	2005-07-26 04:40:44

Modified files:
	gcc            : ChangeLog 
	gcc/config/m68k: m68k.md m68k.h m68k.c m68k-protos.h 

Log message:
	Backport from mainline:
	2005-07-12  Peter Barada  <peter@the-baradas.com>
	PR middle-end/16719
	PR middle-end/18421
	* config/m68k/m68k.h (HARD_REGNO_MODE_OK): Disallow bytes
	in address registers.
	* config/m68k/m68k.c (hard_regno_mode_ok): Likewise.
	* config/m68k/m68k.md: Replace 's' with 'i' in 4th
	alternative of addsi3_5200.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.331&r2=2.7592.2.332
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k.md.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.80&r2=1.80.34.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.123&r2=1.123.10.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.144&r2=1.144.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/m68k/m68k-protos.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.17&r2=1.17.18.1

Comment 21 Andrew Pinski 2005-07-26 20:33:39 UTC
Fixed.