Bug 21291 - [4.0/4.1 Regression] can't find a register in class 'GENERAL_REGS' while reloading 'asm'
Summary: [4.0/4.1 Regression] can't find a register in class 'GENERAL_REGS' while relo...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Richard Henderson
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2005-04-29 21:22 UTC by Pawel Sikora
Modified: 2005-08-05 02:34 UTC (History)
7 users (show)

See Also:
Host:
Target: i686-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-08-04 20:59:58


Attachments
testcase (4.25 KB, text/plain)
2005-04-29 21:22 UTC, Pawel Sikora
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2005-04-29 21:22:16 UTC
works with -O0, fails with -O[123]. 
 
gcc-4.0.0 + patches for pr20973,21173.
Comment 1 Pawel Sikora 2005-04-29 21:22:50 UTC
Created attachment 8768 [details]
testcase
Comment 2 Andrew Pinski 2005-04-29 21:27:51 UTC
This is most likely not really a bug.
Comment 3 Pawel Sikora 2005-04-29 21:43:48 UTC
(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 :/ 
Comment 4 Andrew Pinski 2005-04-29 21:45:44 UTC
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.
Comment 5 Andrew Pinski 2005-04-29 21:58:35 UTC
(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.
Comment 6 Uroš Bizjak 2005-04-30 08:25:02 UTC
Could this be related to PR19398: secondary reloads don't consider "m" alternatives?
Comment 7 Pawel Sikora 2005-04-30 09:35:24 UTC
(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. 
 
Comment 8 Andrew Pinski 2005-06-19 13:04:40 UTC
*** Bug 22045 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Pinski 2005-07-01 20:02:27 UTC
: Search converges between 2004-05-11-trunk (#454) and 2004-05-14-trunk (#455).
Comment 10 Mark Mitchell 2005-07-06 17:03:23 UTC
Postponed until 4.0.2.
Comment 11 Kean Johnston 2005-08-03 01:52:31 UTC
FWIW, same problem occurs on UnixWare.
Comment 12 Richard Henderson 2005-08-04 20:48:53 UTC
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.
Comment 13 GCC Commits 2005-08-04 23:37:15 UTC
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

Comment 14 GCC Commits 2005-08-05 02:33:23 UTC
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

Comment 15 Richard Henderson 2005-08-05 02:34:05 UTC
Fixed.