public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q"
@ 2009-03-30 18:17 felix-gcc at fefe dot de
2009-03-30 19:19 ` [Bug inline-asm/39590] " hjl dot tools at gmail dot com
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: felix-gcc at fefe dot de @ 2009-03-30 18:17 UTC (permalink / raw)
To: gcc-bugs
I am trying to write an inline asm statement that atomically adds a number to a
memory variable. Here's what I came up with:
#define atomic_add(mem,val) asm volatile ("lock; add%z0 %1, %0": "+m" (mem):
"ir" (val))
This appears to work fine on x86, but in 64-bit mode %z returns "ll" instead of
"q" for 64-bit values like size_t, and thus the assembler complains like this:
t.c:53: Error: no such instruction: `addll $3,x.5802(%rip)'
If I understand %z correctly, this is exactly what it is meant for... right?
Please make it return "q" in this case.
--
Summary: inline asm %z on amd64 says "ll" instead of "q"
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: felix-gcc at fefe dot de
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
@ 2009-03-30 19:19 ` hjl dot tools at gmail dot com
2009-03-30 19:55 ` felix-gcc at fefe dot de
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-30 19:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from hjl dot tools at gmail dot com 2009-03-30 19:19 -------
Please provide a testcase.
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl dot tools at gmail dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
2009-03-30 19:19 ` [Bug inline-asm/39590] " hjl dot tools at gmail dot com
@ 2009-03-30 19:55 ` felix-gcc at fefe dot de
2009-03-30 20:00 ` hjl dot tools at gmail dot com
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: felix-gcc at fefe dot de @ 2009-03-30 19:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from felix-gcc at fefe dot de 2009-03-30 19:54 -------
Uh, I did. Use the macro like this:
int foo=2;
atomic_add(foo,3);
then try size_t as type of foo and compile on x86_64.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
2009-03-30 19:19 ` [Bug inline-asm/39590] " hjl dot tools at gmail dot com
2009-03-30 19:55 ` felix-gcc at fefe dot de
@ 2009-03-30 20:00 ` hjl dot tools at gmail dot com
2009-03-30 20:27 ` felix-gcc at fefe dot de
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-30 20:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from hjl dot tools at gmail dot com 2009-03-30 19:59 -------
(In reply to comment #2)
> Uh, I did. Use the macro like this:
>
> int foo=2;
> atomic_add(foo,3);
>
> then try size_t as type of foo and compile on x86_64.
>
That is not a testcase. I need a valid C source code, which
I can compile.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (2 preceding siblings ...)
2009-03-30 20:00 ` hjl dot tools at gmail dot com
@ 2009-03-30 20:27 ` felix-gcc at fefe dot de
2009-03-30 21:07 ` hjl dot tools at gmail dot com
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: felix-gcc at fefe dot de @ 2009-03-30 20:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from felix-gcc at fefe dot de 2009-03-30 20:27 -------
#include <stddef.h>
#define atomic_add(mem,val) asm volatile ("lock; add%z0 %1, %0": "+m" (mem):
"ir" (val))
int main() {
size_t foo;
atomic_add(foo,23);
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (3 preceding siblings ...)
2009-03-30 20:27 ` felix-gcc at fefe dot de
@ 2009-03-30 21:07 ` hjl dot tools at gmail dot com
2009-03-30 22:11 ` felix-gcc at fefe dot de
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-30 21:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from hjl dot tools at gmail dot com 2009-03-30 21:07 -------
'z' is for x87 insns. You have to check size of size_t and use
proper suffix in your code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (4 preceding siblings ...)
2009-03-30 21:07 ` hjl dot tools at gmail dot com
@ 2009-03-30 22:11 ` felix-gcc at fefe dot de
2009-03-31 1:28 ` hjl dot tools at gmail dot com
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: felix-gcc at fefe dot de @ 2009-03-30 22:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from felix-gcc at fefe dot de 2009-03-30 22:10 -------
> 'z' is for x87 insns.
Uh, what?! Let me quote the relevant "documentation"
(gcc/config/i386/i386.md):
;; The special asm out single letter directives following a '%' are:
;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
;; operands[1].
No mention of floating point.
> You have to check size of size_t and use
> proper suffix in your code.
No. The whole point of %z is that you can write asm statements in a way that
does not specify the argument size explicitly in the statement.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (5 preceding siblings ...)
2009-03-30 22:11 ` felix-gcc at fefe dot de
@ 2009-03-31 1:28 ` hjl dot tools at gmail dot com
2009-03-31 22:42 ` hjl dot tools at gmail dot com
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-31 1:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from hjl dot tools at gmail dot com 2009-03-31 01:28 -------
(In reply to comment #6)
> > 'z' is for x87 insns.
>
> Uh, what?! Let me quote the relevant "documentation"
> (gcc/config/i386/i386.md):
>
> ;; The special asm out single letter directives following a '%' are:
> ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
> ;; operands[1].
>
This was written before x86-64 and movq is mentioned here. 64bit is for
fildll/fildq. I don't know if all x86-64 assemblers support fildq.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (6 preceding siblings ...)
2009-03-31 1:28 ` hjl dot tools at gmail dot com
@ 2009-03-31 22:42 ` hjl dot tools at gmail dot com
2009-04-01 1:09 ` hjl dot tools at gmail dot com
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-31 22:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from hjl dot tools at gmail dot com 2009-03-31 22:42 -------
Darwin assembler and GNU assembler support fildq (%rax). But
Solaris assembler doesn't. Only fildll works with all assemblers.
We can't generate the 'q' suffix for "%z".
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ubizjak at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (7 preceding siblings ...)
2009-03-31 22:42 ` hjl dot tools at gmail dot com
@ 2009-04-01 1:09 ` hjl dot tools at gmail dot com
2009-04-01 19:09 ` hjl dot tools at gmail dot com
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-04-01 1:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from hjl dot tools at gmail dot com 2009-04-01 01:08 -------
I don't think it will hurt to generate fildq in 64bit if
assembler supports it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (8 preceding siblings ...)
2009-04-01 1:09 ` hjl dot tools at gmail dot com
@ 2009-04-01 19:09 ` hjl dot tools at gmail dot com
2009-04-16 18:34 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-04-01 19:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from hjl dot tools at gmail dot com 2009-04-01 19:09 -------
A patch is posted at
http://gcc.gnu.org/ml/gcc-patches/2009-04/msg00112.html
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2009-
| |04/msg00112.html
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (9 preceding siblings ...)
2009-04-01 19:09 ` hjl dot tools at gmail dot com
@ 2009-04-16 18:34 ` pinskia at gcc dot gnu dot org
2009-04-25 8:11 ` uros at gcc dot gnu dot org
2009-04-25 8:23 ` ubizjak at gmail dot com
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-04-16 18:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pinskia at gcc dot gnu dot org 2009-04-16 18:34 -------
Stop setting the target milestone unless it is a regression.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.5.0 |---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (10 preceding siblings ...)
2009-04-16 18:34 ` pinskia at gcc dot gnu dot org
@ 2009-04-25 8:11 ` uros at gcc dot gnu dot org
2009-04-25 8:23 ` ubizjak at gmail dot com
12 siblings, 0 replies; 14+ messages in thread
From: uros at gcc dot gnu dot org @ 2009-04-25 8:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from uros at gcc dot gnu dot org 2009-04-25 08:11 -------
Subject: Bug 39590
Author: uros
Date: Sat Apr 25 08:10:51 2009
New Revision: 146761
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146761
Log:
PR target/39590
* configure.ac (HAVE_AS_IX86_FILDQ): On x86 targets check whether
the configured assembler supports fildq and fistpq mnemonics.
(HAVE_AS_IX86_FILDS): Rename from HAVE_GAS_FILDS_FISTS.
* configure: Regenerated.
* config.in: Ditto.
* config/i386/i386.c (print_operand): Handle 'Z'.
['z']: Remove handling of special fild/fist suffixes.
(output_fix_trunc): Use '%Z' to output suffix of fist{,p,tp} insn.
* config/i386/i386.md (*floathi<mode>2_i387): Use '%Z' to output
suffix of fild insn.
(*floatsi<mode>2_vector_mixed): Ditto.
(*float<SSEMODEI24:mode><MODEF:mode>2_mixed_interunit): Ditto.
(*float<SSEMODEI24:mode><MODEF:mode>2_mixed_nointerunit): Ditto.
(*float<SSEMODEI24:mode><X87MODEF:mode>2_i387_with_temp): Ditto.
(*float<SSEMODEI24:mode><X87MODEF:mode>2_i387): Ditto.
* config/i386/gas.h (GAS_MNEMONICS): Remove.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config.in
trunk/gcc/config/i386/gas.h
trunk/gcc/config/i386/i386.c
trunk/gcc/config/i386/i386.md
trunk/gcc/configure
trunk/gcc/configure.ac
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug inline-asm/39590] inline asm %z on amd64 says "ll" instead of "q"
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
` (11 preceding siblings ...)
2009-04-25 8:11 ` uros at gcc dot gnu dot org
@ 2009-04-25 8:23 ` ubizjak at gmail dot com
12 siblings, 0 replies; 14+ messages in thread
From: ubizjak at gmail dot com @ 2009-04-25 8:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from ubizjak at gmail dot com 2009-04-25 08:23 -------
Fixed for 4.5.0.
--
ubizjak at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39590
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2009-04-25 8:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-30 18:17 [Bug inline-asm/39590] New: inline asm %z on amd64 says "ll" instead of "q" felix-gcc at fefe dot de
2009-03-30 19:19 ` [Bug inline-asm/39590] " hjl dot tools at gmail dot com
2009-03-30 19:55 ` felix-gcc at fefe dot de
2009-03-30 20:00 ` hjl dot tools at gmail dot com
2009-03-30 20:27 ` felix-gcc at fefe dot de
2009-03-30 21:07 ` hjl dot tools at gmail dot com
2009-03-30 22:11 ` felix-gcc at fefe dot de
2009-03-31 1:28 ` hjl dot tools at gmail dot com
2009-03-31 22:42 ` hjl dot tools at gmail dot com
2009-04-01 1:09 ` hjl dot tools at gmail dot com
2009-04-01 19:09 ` hjl dot tools at gmail dot com
2009-04-16 18:34 ` pinskia at gcc dot gnu dot org
2009-04-25 8:11 ` uros at gcc dot gnu dot org
2009-04-25 8:23 ` ubizjak at gmail dot com
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).