Bug 14700 - [3.3 Regression ] ICE in verify_wide_reg with global registers
Summary: [3.3 Regression ] ICE in verify_wide_reg with global registers
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.4
: P2 critical
Target Milestone: 3.3.5
Assignee: Eric Christopher
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2004-03-23 22:24 UTC by Debian GCC Maintainers
Modified: 2004-10-30 21:10 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.3 3.3 3.3.1 3.3.2 3.4.2 3.3.5 4.0.0
Known to fail: 3.3.3 3.3.4 3.4.0 3.4.1
Last reconfirmed: 2004-03-29 19:25:55


Attachments
combine.c patch (428 bytes, patch)
2004-04-02 08:25 UTC, Eric Christopher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2004-03-23 22:24:59 UTC
[forwarded from http://bugs.debian.org/239569]

3.2.3 works ok. current 3.3 and 3.4 CVS fail.

he attached code causes the following behaviour: 
hawkinsp@vice:~/tmp$ gcc -O test6.c -o test6 
test6.c: In function `float_module21': 
test6.c:21: internal compiler error: in verify_wide_reg, at flow.c:549 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
test6.c is actually a stripped down and cleaned up version of the 
preprocessed source code from library/float.c in the Mercury Release 
of the Day available from: 
http://www.cs.mu.oz.au/research/mercury/download/files/beta-releases/rotd/mercury-compiler-rotd\
_2004_03_19_unstable-1.src.rpm 
(run it through rpm2cpio and extract the resulting cpio archive to get a 
tarball). 
 
The testcase is the output of the Mercury compiler itself, hence the slightly 
strange code. 


int MR_is_inf(double); 
 
register unsigned int MR_mr1 __asm__ ("edi"); 
register unsigned int MR_mr2 __asm__ ("ebx"); 
 
static void 
float_module21 (void) 
{ 
    (MR_mr2) = 0; 
        (MR_mr2) = MR_is_inf (0.0);  
     if (!(MR_mr2))  
         { 
            goto mercury__float__is_nan_or_inf_1_0_i7; 
         } 
 
      __asm__ __volatile__ ("/* " "mercury__float__is_nan_or_inf_1_0_i7" "*/\n");  
 
mercury__float__is_nan_or_inf_1_0_i7: 
        goto *(((void *) ((MR_mr1)))); 
   
}
Comment 1 Andrew Pinski 2004-03-23 22:55:16 UTC
Confirmed a regression from 3.3.1.
Comment 2 Eric Botcazou 2004-03-29 09:15:28 UTC
And even from 3.3.2.
Comment 3 Eric Botcazou 2004-03-29 10:27:23 UTC
The regression was introduced by:

    2003-05-14  Eric Christopher  <echristo@redhat.com>

	* combine.c: Fix header comments.
	(distribute_notes): Remove usage of elim_i1, elim_i2. Propagate
	to all calls and prototype.

which was backported to the 3.3 branch by:

    2003-12-16  Zack Weinberg  <zack@codesourcery.com>

	Backport the following patches from mainline.


The assignment

  (MR_mr2) = 0;

is wrongly deleted by the combiner.  This probably means that global register
variables are still broken.
Comment 4 Eric Christopher 2004-03-29 19:25:54 UTC
Strange since the code I deleted was, in fact, optimization code for combine.
So, my patch did _less_ than we did before. This is probably exposing a bug
somewhere else in the compiler, but I'll take a look and see what i can find.
Comment 5 Mark Mitchell 2004-04-01 23:19:45 UTC
Since this generates an ICE, not wrong-code, and since global register variables
are pretty rare, I've retargeted this at 3.4.1.
Comment 6 Eric Christopher 2004-04-02 08:25:35 UTC
Created attachment 6032 [details]
combine.c patch

Here's a patch that I'm testing. it passes the testcase and seems to do what we
want. I'm not positive it's correct though so I'll submit it.
Comment 7 Eric Christopher 2004-04-02 08:29:11 UTC
I'll also use the testcase and put it into the gcc testsuite if that's cool?
Comment 8 Mark Mitchell 2004-06-19 00:01:56 UTC
Eric, this patch is OK for mainline and for 3.4.2 -- but not for 3.4.1 at this
late date.

Postponed until GCC 3.4.2.
Comment 9 Debian GCC Maintainers 2004-06-19 11:03:13 UTC
applied to the 3.3.4 release, the patch results in a bootstrap error on i486-linux:

stage1/xgcc -Bstage1/ -B/usr/i486-linux/bin/ -c   -g -O2  -DIN_GCC   -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic
-Wno-long-long   -DHAVE_CONFIG_H -DGENERATOR_FILE    -I. -I. -I../../src/gcc
-I../../src/gcc/. -I../../src/gcc/config -I../../src/gcc/../include
../../src/gcc/genautomata.c -o genautomata.o
../../src/gcc/genautomata.c: In function `finish_regexp_representation':
../../src/gcc/genautomata.c:6777: internal compiler error: in find_free_reg, at
local-alloc.c:2182
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[4]: *** [genautomata.o] Error 1
Comment 10 Eric Christopher 2004-06-19 15:53:57 UTC
Almost positive that's because of a flow patch that's not in 3.3.4 (or 3.4
branch as of the time I did this), but is in mainline and i'll verify 3.4 branch
as well.
Comment 11 Eric Christopher 2004-06-24 18:53:28 UTC
Still seems like we're missing a flow patch on the branch that I haven't had
time to dig up so definitely postponing this one. I'll see if I can track it
down at some point. Committing the combine patch to mainline though.
Comment 12 Giovanni Bajo 2004-06-30 03:23:33 UTC
Patch was committed to mainline but the Changelog didn't contain the PR to 
crossreference it:
http://gcc.gnu.org/ml/gcc-cvs/2004-06/msg01010.html

Notice that the patch had a latent bug, which was later fixed on mainline by 
Zack: http://gcc.gnu.org/ml/gcc-patches/2004-06/msg02558.html

So when the patch is backported to 3.4 and 3.3 it will need also the followup 
patch.
Comment 13 Debian GCC Maintainers 2004-06-30 23:13:09 UTC
3.3.4 + the combined patch fix this on i486-linux, no new regressions in the
testsuite.

    Matthias
Comment 14 GCC Commits 2004-07-06 21:12:26 UTC
Subject: Bug 14700

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	echristo@gcc.gnu.org	2004-07-06 21:12:17

Modified files:
	gcc            : ChangeLog combine.c 

Log message:
	2004-07-06  Eric Christopher  <echristo@redhat.com>
	
	PR rtl-optimization/14700
	Backport from mainline:
	2004-06-30  Zack Weinberg  <zack@codesourcery.com>
	* combine.c (distribute_notes): Don't look at global_regs for
	pseudos.
	
	2004-06-24  Eric Christopher  <echristo@redhat.com>
	* combine.c (distribute_notes): Don't delete sets to
	global register variables.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.528&r2=2.2326.2.529
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.400.4.8&r2=1.400.4.9

Comment 15 GCC Commits 2004-07-25 18:49:57 UTC
Subject: Bug 14700

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	doko@gcc.gnu.org	2004-07-25 18:49:56

Modified files:
	gcc            : ChangeLog combine.c 

Log message:
	2004-07-25  Matthias Klose  <doko@debian.org>
	
	Backport:
	PR rtl-optimization/14700
	
	2004-06-24  Eric Christopher  <echristo@redhat.com>
	
	* combine.c (distribute_notes): Don't delete sets to
	global register variables.
	
	2004-06-29  Zack Weinberg  <zack@codesourcery.com>
	
	* combine.c (distribute_notes): Don't look at global_regs for
	pseudos.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1003&r2=1.16114.2.1004
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.325.2.16&r2=1.325.2.17

Comment 16 Andrew Pinski 2004-07-25 19:05:54 UTC
Fixed in 3.3.5, 3.4.2 and 3.5.0.