public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
@ 2003-05-10 21:16 Dara Hazeghi
  0 siblings, 0 replies; 5+ messages in thread
From: Dara Hazeghi @ 2003-05-10 21:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR inline-asm/9637; it has been noted by GNATS.

From: Dara Hazeghi <dhazeghi@yahoo.com>
To: gcc-gnats@gcc.gnu.org, pgw99@doc.ic.ac.uk
Cc:  
Subject: Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
Date: Sat, 10 May 2003 14:07:50 -0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- 
 trail&database=gcc&pr=9637
 
 Hello,
 
 with gcc 3.2.3, I get the same error as mentioned in the report. With  
 3.3 branch or mainline I get:
 
 junk.c: In function `AMD_sqrt':
 junk.c:7: error: impossible constraint in `asm'
 
 It seems that the crash has been solved, and we now exit gracefully.  
 Can the submitter verify if the code in question is in fact faulty?  
 Thanks,
 
 Dara
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
@ 2003-05-12 12:36 Philip Graham Willoughby
  0 siblings, 0 replies; 5+ messages in thread
From: Philip Graham Willoughby @ 2003-05-12 12:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR inline-asm/9637; it has been noted by GNATS.

From: Philip Graham Willoughby <pgw99@doc.ic.ac.uk>
To: Dara Hazeghi <dhazeghi@yahoo.com>, gcc-gnats@gcc.gnu.org,
	pgw99@doc.ic.ac.uk, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	nobody@gcc.gnu.org
Cc:  
Subject: Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
Date: Mon, 12 May 2003 13:26:07 +0100

 --n8g4imXOkfNTN/H1
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-trail&database=3D=
 gcc&pr=3D9637
 
 On 2003-05-10 14:07:50 +0000, Dara Hazeghi wrote:
 >=20
 > It seems that the crash has been solved, and we now exit gracefully. =20
 > Can the submitter verify if the code in question is in fact faulty? =20
 
 I now have a somewhat better understanding of inline asm than when I submit=
 ted
 this bug.
 
 Here is an explanation of what the operative (well, problematic) lines of t=
 his
 code:
 
 : "=3Dy" (c), "=3Dy" (a), "=3Dy" (b)
 : "0" (c)
 
 are actually supposed to do.
 
 The first line means "Pick three MMX registers.  These will contain the val=
 ues
 of c, a and b at the end of the ASM instructions.  I've called them $y0, %y1
 and %y2 inside the asm block, and I need you to substitute those names with=
  the
 names of the registers you picked."
 
 The second line means "Remember the first register you picked?  Well, I want
 you to put the value of c into it before running the ASM block."
 
 So far this matches what the documentation says.
 
 Now, on to the reasons I think that this code might have failed:
 
 * Reason 1:
 
 The function tries to use a FP value and the MMX registes in the same funct=
 ion,
 and you can't mix FP calls and MMX calls indiscriminately.
 
 - Good Solution:
 Fix gcc to add the appropriate calls to save/restore the FP stack before/af=
 ter
 asm blocks which use MMX registers
 
 - Bad Solution:
 Change the documentation so it says "You cannot mix FP and MMX calls in the
 same function."
 
 * Reason 2:
 
 GCC doesn't actually understand how to pass things to/from MMX registers.
 
 - Good Solution:
 Fix gcc to bring it in line with what the docs say.
 
 - Bad Solution:
 Change the docs to remove references to MMX register constraints to asm.
 
 * Reason 3:
 
 GCC doesn't know how to move a "long long" value into or out of an MMX
 register.
 
 - Good Solution:
 Teach it how - they are the same length, so it ought not to be a problem.
 Alignment _may_ be an issue however.
 
 - Bad Solution:
 Change the docs to say it doesn't work.  That would raise the question of w=
 hat
 in fact gcc can move into an MMX register...
 
 Hope all this helps.  The bottom line is that the code as written should wo=
 rk
 if gcc behaves as documented.  I can't assure you that the asm actually wor=
 ks
 when compiled because I have never persuaded gcc to compile it ;-), plus of
 course there are better instructions to do the same from the SSE instruction
 set.  I'd still like to resolve this as a fallback path for k6 and pre-xp
 athlon processors.
 
 Regards,
 
 Philip Willoughby
 
 Systems Programmer, Department of Computing, Imperial College, London, UK
 --=20
 echo bzidd@nfo.ho.co.se | tr "bizndfohces" "pwgd9ociaku"
 
 Why reinvent the wheel?
 Because we can make it rounder...
 
 --n8g4imXOkfNTN/H1
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.2 (GNU/Linux)
 
 iD8DBQE+v5Lei294YDsKgb0RAs45AJ4tkK74mdvT4d3fqPWs4WQ6nW/5vgCfWftw
 9bTsuY7NSxyhKxF0df7zOzg=
 =6g+R
 -----END PGP SIGNATURE-----
 
 --n8g4imXOkfNTN/H1--


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
@ 2003-05-12 12:34 steven
  0 siblings, 0 replies; 5+ messages in thread
From: steven @ 2003-05-12 12:34 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, pgw99

Synopsis: arguments passed/return to asm block via mmx registers trigger failure

State-Changed-From-To: feedback->analyzed
State-Changed-By: steven
State-Changed-When: Mon May 12 12:34:57 2003
State-Changed-Why:
    Feedback received -- thank!

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9637


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
@ 2003-05-12 11:16 giovannibajo
  0 siblings, 0 replies; 5+ messages in thread
From: giovannibajo @ 2003-05-12 11:16 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, pgw99

Synopsis: arguments passed/return to asm block via mmx registers trigger failure

State-Changed-From-To: open->feedback
State-Changed-By: bajo
State-Changed-When: Mon May 12 11:14:50 2003
State-Changed-Why:
    See Dara's question.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9637


^ permalink raw reply	[flat|nested] 5+ messages in thread

* inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
@ 2003-02-09 18:56 pgw99
  0 siblings, 0 replies; 5+ messages in thread
From: pgw99 @ 2003-02-09 18:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9637
>Category:       inline-asm
>Synopsis:       arguments passed/return to asm block via mmx registers trigger failure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Feb 09 18:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Philip Graham Willoughby
>Release:        gcc-3.2.2
>Organization:
>Environment:
SuSE Linux 7.2, glibc 2.2.2, binutils 2.13.1
>Description:
This error occurs with -O:
test.c: In function `AMD_sqrt':
test.c:18: Internal compiler error in fixup_var_refs_1, at function.c:1966

and this error without:
test.c: In function `AMD_sqrt':
test.c:18: Internal compiler error in instantiate_virtual_regs_1, at function.c:3971

When attempting to compile the following:

float
AMD_sqrt (float param)
{
  long long a, b, c;
  memcpy (&c, &param, sizeof (float));
  c >>= 32;
  asm("pfrsqrt    %y1, %y0 \n\t"
      "movq       %y2, %y1 \n\t"
      "pfmul      %y1, %y1 \n\t"
      "pfrsqit1   %y1, %y0 \n\t"
      "pfrcpit2   %y1, %y2 \n\t"
      "pfmul      %y0, %y1 \n\t"
      : "=y" (c), "=y" (a), "=y" (b)
      :"0" (c));
  memcpy (&param, &c, sizeof (float));
  c <<= 32;
  return param;
}

I have not used MMX assembler in GCC before, so I am willing to be told I'm responsible for this error.  However, I think it'd be best if it didn't fail in quite so dramatic a way.
>How-To-Repeat:
gcc -c -o test.o test.c

Where test.c contains the above code.  Adding/removing -O will let you see both cases.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-12 12:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-10 21:16 inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure Dara Hazeghi
  -- strict thread matches above, loose matches on Subject: below --
2003-05-12 12:36 Philip Graham Willoughby
2003-05-12 12:34 steven
2003-05-12 11:16 giovannibajo
2003-02-09 18:56 pgw99

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).