Bug 36336 - ICE push_reload - psuedo reg_equiv_constant
Summary: ICE push_reload - psuedo reg_equiv_constant
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-26 19:22 UTC by Andy Hutchinson
Modified: 2008-06-15 18:36 UTC (History)
3 users (show)

See Also:
Host: i686-pc-cygwin
Target: avr-unknown-none
Build: i686-pc-cygwin
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Testcase (260 bytes, text/plain)
2008-05-26 19:24 UTC, Andy Hutchinson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Hutchinson 2008-05-26 19:22:26 UTC
The follow ICE occurs with various testsuite tests. It appears to be real bug.

Executing on host: /home/hutchia/Desktop/awhconf/gcc/xgcc -B/home/hutchia/Desktop/awhconf/gcc/   -O2  -w -DSTACK_SIZE=2048 -DNO_TRAMPOLINES -fno-show-column -c  -DSIGNAL_SUPPRESS -mmcu=atmega128   -o 980408-1.o /home/hutchia/Desktop/gcc/gcc/testsuite/gcc.c-torture/compile/980408-1.c    (timeout = 300)
/home/hutchia/Desktop/gcc/gcc/testsuite/gcc.c-torture/compile/980408-1.c: In function 'MinifyImage':
/home/hutchia/Desktop/gcc/gcc/testsuite/gcc.c-torture/compile/980408-1.c:129: internal compiler error: in push_reload, at reload.c:940


The assertion failure is due to push_reload receiving pseudo (e.g. p68) that has not replaced with its reg_equiv_constant.

The assert was added by this bug fix:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34641


Analysis

push_reload is called by target LEGITIMIZE_RELOAD_ADDRESS. This received  operand p68 + 2 and is attempting to reload p68.

LEGITIMIZE_RELOAD_ADDRESS was invoked by find_reloads_address after strict_memory_address_p rejects  p68+2.

The assert was added 
2008-01-10  Andreas Krebbel  <krebbel1@de.ibm.com>

This also added extra code to convert pseudo register equivalent constants were converted by before push_reload is called. However, it does not consider the case where the operand is a sum of reg_equiv_reg and constant.

This does not get replaced before LEGITIMIZE_RELOAD_ADDRESS is called in 
find_reloads_address.


The internals manual clearly indicates that GO_IF_LEGITIMATE_ADDRESS should reject p68+2 unless there is const wrapper.

http://gcc.gnu.org/onlinedocs/gccint/Addressing-Modes.html

But the call from reload does not seem to provide that wrapper. Perhaps this is the bug?

I have attached the smallest testcase. It is nonsense but will cause failure
when compiled using:

avr-gcc -c -mmcu=atmega128  -w  -O1 -mmcu=atmega128  -std=gnu99 memcpy-chk.c -o memcpy-chk.o


The attached testcase uses __builtin_setjmp as a reduction from a failing test. However, the ICE is not unique to this function. gcc/gcc/testsuite/gcc.c-torture/compile/980408-1.c also fails and this does not use _builtin_setjmp. But I was unable to create small testcase from this.
Comment 1 Andy Hutchinson 2008-05-26 19:24:22 UTC
Created attachment 15688 [details]
Testcase

Testcase derived from gcc testsuite failure memcpy-chk.c
Comment 2 Eric Weddington 2008-06-06 19:24:34 UTC
Andy, I'm having a difficulty in trying to reproduce this bug. I use this command line:
avr-gcc -O1 -mmcu=atmega128 -w -std=gnu99 -c memcpy-chk.c -o memcpy-chk.o
But I'm using WinAVR 20080512, which is patched, and it does not give an ICE.

Are you also getting this ICE with HEAD?
Comment 3 Andy Hutchinson 2008-06-06 19:42:38 UTC
Subject: Re:  ICE push_reload - psuedo reg_equiv_constant

O2



----------------------------------------------
Sent from my Dingleberry wired device.


-----Original Message-----
From: eric dot weddington at atmel dot com <gcc-bugzilla@gcc.gnu.org>
To: hutchinsonandy@aim.com
Sent: Fri, 6 Jun 2008 3:24 pm
Subject: [Bug target/36336] ICE push_reload - psuedo reg_equiv_constant




------- Comment #2 from eric dot weddington at atmel dot com  
2008-06-06 19:24
-------
Andy, I'm having a difficulty in trying to reproduce this bug. I use 
this
command line:
avr-gcc -O1 -mmcu=atmega128 -w -std=gnu99 -c memcpy-chk.c -o 
memcpy-chk.o
But I'm using WinAVR 20080512, which is patched, and it does not give 
an ICE.

Are you also getting this ICE with HEAD?


--


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36336

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.

Comment 4 Eric Weddington 2008-06-06 19:48:26 UTC
Test case passes with -O[0123s], with WinAVR 20080512 (patched 4.3.0).
Comment 5 Andy Hutchinson 2008-06-06 20:18:53 UTC
Subject: Re:  ICE push_reload - psuedo reg_equiv_constant


The patch for

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31786

removes one problematic part of LEGITIMIZE_RELOAD_ADDRESS. This is  
applied to WinAVR 20080512 (patched 4.3.0). But is still waiting for 
approval on avr-gcc 4.3/4.4 HEAD.

Even with that patch, the other parts of L_R_A are bad and need fixing 
with added check of reg_equivalent_constant.
So if register is equivalent constant LEGITIMIZE_RELOAD_ADDRESS should 
do nothing.

The assert that triggers is an explicit check for this.

I have not posted patch due to overlap with pending patch.

BTW gcc list has short discussion on this bug, including explanation 
for the AVR code.

Andy




----------------------------------------------
Sent from my Dingleberry wired device.


-----Original Message-----
From: eric dot weddington at atmel dot com <gcc-bugzilla@gcc.gnu.org>
To: hutchinsonandy@aim.com
Sent: Fri, 6 Jun 2008 3:48 pm
Subject: [Bug target/36336] ICE push_reload - psuedo reg_equiv_constant




------- Comment #4 from eric dot weddington at atmel dot com  
2008-06-06 19:48
-------
Test case passes with -O[0123s], with WinAVR 20080512 (patched 4.3.0).


--


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36336

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.

Comment 6 Andy Hutchinson 2008-06-15 18:25:11 UTC
Subject: Bug 36336

Author: hutchinsonandy
Date: Sun Jun 15 18:24:27 2008
New Revision: 136818

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136818
Log:
PR target/36336
* config/avr/avr.h (LEGITIMIZE_RELOAD_ADDRESS): Add check for reg_equiv_constant.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.h

Comment 7 Andy Hutchinson 2008-06-15 18:35:30 UTC
Subject: Bug 36336

Author: hutchinsonandy
Date: Sun Jun 15 18:34:45 2008
New Revision: 136819

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136819
Log:
PR target/36336
* config/avr/avr.h (LEGITIMIZE_RELOAD_ADDRESS): Add check for reg_equiv_constant.

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/avr/avr.h

Comment 8 Andy Hutchinson 2008-06-15 18:36:23 UTC
Fixed 4.4 and 4.3