This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
I wanted to compile the NetBSD GENERIC kernel. gcc 3.2 failed with this: cc -ffreestanding -O0 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wno-uninitialized -Di386 -I. -I../../../../arch -I../../../.. -nostdinc -DLKM -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -c /sys/arch/i386/compile/GENERIC/../../../../dev/pci/if_pcn.c /sys/dev/pci/if_pcn.c: In function `pcn_init': /sys/dev/pci/if_pcn.c:1767: unrecognizable insn: (insn 640 639 641 (parallel[ (set (reg:CCZ 17 flags) (compare:CCZ (const_int 512 [0x200]) (const_int 0 [0x0]))) (set (reg:SI 203) (unspec:SI[ (const_int 512 [0x200]) ] 5)) ] ) -1 (nil) (nil)) /sys/dev/pci/if_pcn.c:1767: Internal compiler error in extract_insn, at recog.c:2148 This does only happen with with the option -O0 or if I use no -Ox at all. The compiler does not fail if I use -O1,-O2 or -O3. FYI, gcc 2.95.3 has a problem with the same piece of code as well: /usr/bin/cc -ffreestanding -O0 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wno-uninitialized -Di386 -I. -I../../../../arch -I../../../.. -nostdinc -DLKM -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -c /sys/arch/i386/compile/GENERIC/../../../../dev/pci/if_pcn.c /sys/arch/i386/compile/GENERIC/../../../../dev/pci/if_pcn.c: In function `pcn_init': /sys/arch/i386/compile/GENERIC/../../../../dev/pci/if_pcn.c:1767: internal error--unrecognizable insn: (insn 644 643 646 (set (reg:SI 170) (unspec:SI[ (const_int 512 [0x200]) ] 5)) -1 (nil) (nil)) Release: 3.2 Environment: NetBSD/i386 1.6I How-To-Repeat: Instructions how to build the kernel can be read here: http://www.netbsd.org/Documentation/kernel/#how_to_build_a_kernel I have set the environment variable COPTS to '-O0'. If COPTS is not defined it will default to -O2.
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. The bug can be reproduced with the following line: int main() { return __builtin_ffs(4); } Just compile without optimization on i686-pc-linux-gnu. The bug affects all compilers since 2.95.x.
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de> To: christianbiere@gmx.de, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org Cc: Subject: Re: optimization/8178: __builtin_ffs broken Date: Mon, 10 Mar 2003 16:01:52 +0100 (CET) The problem got apparently fixed on mainline. I'm leaving the PR open, since somebody might want to backport the fix to the 3.3 or 3.2 branch. Regards, Volker http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8178
From: Eric Botcazou <ebotcazou@libertysurf.fr> To: Volker Reichelt <reichelt@igpm.rwth-aachen.de> Cc: hristianbiere@gmx.de, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org Subject: Re: optimization/8178: __builtin_ffs broken Date: Mon, 10 Mar 2003 16:41:50 +0100 > The problem got apparently fixed on mainline. Probably by http://gcc.gnu.org/ml/gcc-patches/2003-02/msg00300.html > I'm leaving the PR open, since somebody might want to backport the fix > to the 3.3 or 3.2 branch. I'm still getting an ICE on k6 though: http://gcc.gnu.org/ml/gcc-patches/2003-03/msg00707.html -- Eric Botcazou
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de> To: christianbiere@gmx.de, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, rth@redhat.com, falk.hueffner@student.uni-tuebingen.de Cc: ebotcazou@libertysurf.fr Subject: Re: optimization/8178: __builtin_ffs broken Date: Wed, 12 Mar 2003 13:30:29 +0100 (CET) I can confirm that the problem is still present on k6. According to Phil's tester the problem for the ix86 was fixed between 2003-01-31 and 2003-02-01. Therefore I strongly suspect that the following patch (by Richard Henderson and Falk Hueffner) was responsible for the fix: http://gcc.gnu.org/ml/gcc-cvs/2003-02/msg00033.html That's why I'm asking you, Richard and Falk, could you please have a look at the patch, whether it really did fix things and if yes, why it doesn't fix the k6-issue and whether the fix can be backported to 3.3 or even 3.2? Thanks, Volker
From: Richard Henderson <rth@redhat.com> To: Volker Reichelt <reichelt@igpm.rwth-aachen.de> Cc: christianbiere@gmx.de, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, falk.hueffner@student.uni-tuebingen.de, ebotcazou@libertysurf.fr, gcc-patches@gcc.gnu.org Subject: Re: optimization/8178: __builtin_ffs broken Date: Wed, 12 Mar 2003 16:42:15 -0800 On Wed, Mar 12, 2003 at 01:30:29PM +0100, Volker Reichelt wrote: > I can confirm that the problem is still present on k6. > According to Phil's tester the problem for the ix86 was fixed > between 2003-01-31 and 2003-02-01. Backporting the patch you mention isn't an option, but this bug is fixable for 3.2/3.3 trivially. r~ * config/i386/i386.md (ffssi2): Tighten op1 predicate to match the requirements of the output insns. Index: gcc/config/i386/i386.md =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v retrieving revision 1.404.2.10 diff -c -p -d -u -r1.404.2.10 i386.md --- gcc/config/i386/i386.md 12 Mar 2003 09:35:27 -0000 1.404.2.10 +++ gcc/config/i386/i386.md 13 Mar 2003 00:41:08 -0000 @@ -13671,7 +13671,7 @@ (define_expand "ffssi2" [(set (match_operand:SI 0 "nonimmediate_operand" "") - (ffs:SI (match_operand:SI 1 "general_operand" "")))] + (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "")))] "" { rtx out = gen_reg_rtx (SImode), tmp = gen_reg_rtx (SImode);
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed in gcc 3.2 branch, 3.3 branch and mainline.
From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> To: reichelt@igpm.rwth-aachen.de Cc: christianbiere@gmx.de, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: optimization/8178: __builtin_ffs broken Date: 18 Apr 2003 18:23:15 +0200 reichelt@igpm.rwth-aachen.de writes: > Synopsis: __builtin_ffs broken > > State-Changed-From-To: analyzed->closed > State-Changed-By: reichelt > State-Changed-When: Fri Apr 18 15:36:52 2003 > State-Changed-Why: > Fixed in gcc 3.2 branch, 3.3 branch and mainline. It still doesn't work for me on mainline with -march=k6: % cat ffs.c int f(int x) { return __builtin_ffs(x); } % /tmp/bla/bin/gcc -v Reading specs from /usr/tmp/bla/bin/../lib/gcc-lib/i586-pc-linux-gnu/3.4/specs Configured with: ./configure --enable-languages=c --disable-nls Thread model: posix gcc version 3.4 20030415 (experimental) % /tmp/bla/bin/gcc -c ffs.c % /tmp/bla/bin/gcc -c -march=k6 ffs.c ffs.c: In function `f': ffs.c:1: error: unrecognizable insn: (insn 26 22 27 0 0x401705d8 (parallel [ (set (reg:SI 1 edx) (const_int 0 [0x0])) (clobber (reg:CC 17 flags)) ]) -1 (nil) (nil)) ffs.c:1: internal compiler error: in extract_insn, at recog.c:2188 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. -- Falk
State-Changed-From-To: closed->analyzed State-Changed-Why: As Falk pointed out, __builtin_ffs broken is still broken on mainline with -march=k6. The tests ffs-1.c, ffs-2.c from the testsuite Eric mentioned also still fail on mainline. Since this all works on the 3.3 branch, we have a regression.
Confirmed with mainline (20030620). Does not fail with 3.3 branch.
Still happens on the mainline (20030706).
The testcase ----------------------------------------- int main() { return __builtin_ffs(4); } ----------------------------------------- now works on mainline even with -march=k6. This is probably due to Rogers patch http://gcc.gnu.org/ml/gcc-cvs/2003-08/msg00818.html Alas, the following code snippet still fails with -march=k6: ----------------------------------------- int i=4; int main() { return __builtin_ffs(i); } ----------------------------------------- The tests ffs-1.c and ffs-2.c from the testsuite also still fail. Phil's regression tester says: Search converges between 2003-02-04-trunk (#213) and 2003-02-05-trunk (#214).
Richard, could you please have a look, since your patch http://gcc.gnu.org/ml/gcc-cvs/2003-02/msg00241.html caused the regression? Thanks, Volker
Fixing.
Subject: Bug 8178 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2003-10-18 07:25:02 Modified files: gcc : ChangeLog gcc/config/i386: i386.md Log message: PR optimization/8178 * config/i386/i386.md (*movsi_zero): New insn to set a register to zero on TARGET_USE_MOV0 targets. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1459&r2=2.1460 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.484&r2=1.485
See http://gcc.gnu.org/ml/gcc-patches/2003-10/msg01497.html
Subject: Bug 8178 CVSROOT: /cvs/gcc Module name: gcc Changes by: ebotcazou@gcc.gnu.org 2003-10-19 17:53:12 Modified files: gcc : ChangeLog gcc/config/i386: i386.md Log message: PR optimization/8178 * config/i386/i386.md (*movsi_zero): Delete. (*ffs_no_cmove): Use ix86_expand_clear to zero the third operand. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1477&r2=2.1478 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.485&r2=1.486