public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Philip Graham Willoughby <pgw99@doc.ic.ac.uk>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: inline-asm/9637: arguments passed/return to asm block via mmx registers trigger failure
Date: Mon, 12 May 2003 12:36:00 -0000	[thread overview]
Message-ID: <20030512123600.5598.qmail@sources.redhat.com> (raw)

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--


             reply	other threads:[~2003-05-12 12:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-12 12:36 Philip Graham Willoughby [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-05-12 12:34 steven
2003-05-12 11:16 giovannibajo
2003-05-10 21:16 Dara Hazeghi
2003-02-09 18:56 pgw99

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030512123600.5598.qmail@sources.redhat.com \
    --to=pgw99@doc.ic.ac.uk \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).