Bug 37018 - compiling inline assembly for ia32 produces ia64 registers
Summary: compiling inline assembly for ia32 produces ia64 registers
Status: RESOLVED DUPLICATE of bug 23242
Alias: None
Product: gcc
Classification: Unclassified
Component: inline-asm (show other bugs)
Version: 4.3.1
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-04 01:34 UTC by Ed Karrels
Modified: 2008-08-04 08:28 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
preprocessed source (247 bytes, text/plain)
2008-08-04 01:35 UTC, Ed Karrels
Details
Output from "gcc -v -save-temps -O -c foo.c" (745 bytes, text/plain)
2008-08-04 01:37 UTC, Ed Karrels
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Karrels 2008-08-04 01:34:34 UTC
In this sample, which includes inline assembly code, GCC produces assembly that uses 64-bit registers when the target is 32-bit code.  The assembler complains:

foo.c: Assembler messages:
foo.c:17: Error: bad register name `%dil'
Comment 1 Ed Karrels 2008-08-04 01:35:46 UTC
Created attachment 16007 [details]
preprocessed source
Comment 2 Ed Karrels 2008-08-04 01:37:41 UTC
Created attachment 16008 [details]
Output from "gcc -v -save-temps -O -c foo.c"
Comment 3 Ed Karrels 2008-08-04 01:39:44 UTC
(In reply to comment #0)

Bug only occurs with optimization turned on.
Comment 4 Andreas Schwab 2008-08-04 07:44:51 UTC

*** This bug has been marked as a duplicate of 23242 ***
Comment 5 Uroš Bizjak 2008-08-04 07:52:50 UTC
In fact, it is not the duplicate of 23242. 23242 suggests "Q" constraint to access high part of 16bit regs (i.e. ah, dh ...), but here we should use "q" constraint instead of "r" to access lower 8bit part of the register. On 64bit, we can also use i.e. r10b in addition to sil and dil here.
Comment 6 Andreas Schwab 2008-08-04 08:28:03 UTC
Both "Q" and "q" are correct when trying to use the low part of a register.  Only if the asm insn is using the high part you must use "Q".  It is the modifier (%b or %h) that chooses between low and high part.