works with -O0, fails with -O[123]. gcc-4.0.0 + patches for pr20973,21173.
Created attachment 8768 [details] testcase
This is most likely not really a bug.
(In reply to comment #2) > This is most likely not really a bug. I can't build the Objective Caml compiler with this gcc error :/
Reduced testcase: typedef unsigned long bngdigit; typedef bngdigit * bng; typedef unsigned int bngcarry; typedef unsigned long bngsize; bngdigit bng_ia32_mult_sub_digit (bng a , bngsize alen, bng b , bngsize blen, bngdigit d) { bngdigit out, tmp; bngcarry carry; bngdigit a11; alen -= blen; out = 0; asm("" : "+r" (a), "+r" (b), "+mr" (blen), "+mr" (out), "=&r" (tmp) : "mr" (d) : "eax", "edx"); if (alen == 0) {a11 =out; goto t;} a11 = 1; t: return a11; } We are just running out of registers which is what x86 is known for.
(In reply to comment #3) > I can't build the Objective Caml compiler with this gcc error :/ If we change the asm to like so: asm("" : "+r" (a), "+r" (b), "+m" (blen), "+m" (out), "=&r" (tmp) : "m" (d) : "eax", "edx"); We don't get an error. Also using -fomit-frame-pointer works around the problem by adding another free register. What is most likely happening is we are not selecting the secondary constraint. Oh, reload sucks.
Could this be related to PR19398: secondary reloads don't consider "m" alternatives?
(In reply to comment #5) > (In reply to comment #3) > > I can't build the Objective Caml compiler with this gcc error :/ > > (...) > Also using -fomit-frame-pointer works around the problem by adding > another free register. What is most likely happening is we are not > selecting the secondary constraint. this code is a part of library (-fPIC in use). -fomit-frame-pointer won't help.
*** Bug 22045 has been marked as a duplicate of this bug. ***
: Search converges between 2004-05-11-trunk (#454) and 2004-05-14-trunk (#455).
Postponed until 4.0.2.
FWIW, same problem occurs on UnixWare.
The reason that we're rejecting the "m" alternative is that we've expanded "+mr"(blen) to (set (reg/v:SI 60 [ blen.25 ]) (asm_operands:SI ("") ("=mr") 2 [ (mem/i:SI (plus:SI (reg/f:SI 16 argp) (const_int 16 [0x10])) [0 d+0 S4 A32]) (reg/v/f:SI 65 [ a ]) (reg/v/f:SI 67 [ b ]) (reg/v:SI 68 [ blen ]) Note reg 60 as output and reg 68 as input. Probably out-of-ssa is missing the fact that we'd like these variables to be unified.
Subject: Bug 21291 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2005-08-04 23:37:00 Modified files: gcc : ChangeLog tree-outof-ssa.c Added files: gcc/testsuite/gcc.target/i386: pr21291.c Log message: PR 21291 * tree-outof-ssa.c (coalesce_asm_operands): New. (coalesce_ssa_name): Use it. Split out ... (coalesce_phi_operands, coalesce_result_decls): ... these. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9659&r2=2.9660 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-outof-ssa.c.diff?cvsroot=gcc&r1=2.65&r2=2.66 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr21291.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 21291 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: rth@gcc.gnu.org 2005-08-05 02:33:11 Modified files: gcc : ChangeLog tree-outof-ssa.c Added files: gcc/testsuite/gcc.target/i386: pr21291.c Log message: PR 21291 * tree-outof-ssa.c (coalesce_asm_operands): New. (coalesce_ssa_name): Use it. Split out ... (coalesce_phi_operands, coalesce_result_decls): ... these. 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.352&r2=2.7592.2.353 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-outof-ssa.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.47&r2=2.47.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.target/i386/pr21291.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed.