[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)))); }
Confirmed a regression from 3.3.1.
And even from 3.3.2.
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.
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.
Since this generates an ICE, not wrong-code, and since global register variables are pretty rare, I've retargeted this at 3.4.1.
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.
I'll also use the testcase and put it into the gcc testsuite if that's cool?
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.
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
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.
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.
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.
3.3.4 + the combined patch fix this on i486-linux, no new regressions in the testsuite. Matthias
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
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
Fixed in 3.3.5, 3.4.2 and 3.5.0.