Inline assembly - multiple constraints and reloads.

I recently submitted this question to stackoverflow, but it might need the attention of someone more familiar with clang / llvm internals.
I am using Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn).

Inline assembly for a 64 x 64 = 128 bit (x86-64) multiply:

asm (“mulq %q3” : “=a” (rl), “=d” (rh) : “%0” (x), “rm” (y) : “cc”)

yields:

movq %rcx, -8(%rbp)
## InlineAsm Start
mulq -8(%rbp)
## InlineAsm End

which stores and reloads the value. “r” (y) appears to correct this, yielding: mulq %rcx, but at the loss of the range of valid constraints, which could be an issue in the event of register pressure. The optimization level does not seem to affect the result. Furthermore, multiple alternative constraint syntax, such as: “r,m” (y), appears to work, but simply ignores alternatives after the first, as evidenced by: “m,r” (y). Have these issues been resolved or under consideration in current revisions?

I apologize for the bold-type, hyperlinks, etc., in advance. I’m not sure of the posting etiquette. The original stackoverflow question is more concise.

I recently submitted this question to stackoverflow<gcc - clang (LLVM) inline assembly - multiple constraints with useless spills / reloads - Stack Overflow,
but it might need the attention of someone more familiar with clang / llvm
internals.
I am using *Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
*.

Inline assembly for a 64 x 64 = 128 bit (x86-64) multiply:

*__asm__ ("mulq %q3" : "=a" (rl), "=d" (rh) : "%0" (x), "rm" (y) : "cc")*

yields:

*movq %rcx, -8(%rbp)*
*## InlineAsm Start*
*mulq -8(%rbp)*
*## InlineAsm End*

which stores and reloads the value. *"r" (y)* appears to correct this,
yielding: *mulq %rcx*, but at the loss of the range of valid constraints,
which could be an issue in the event of register pressure. The optimization
level does not seem to affect the result. Furthermore, multiple alternative
constraint syntax, such as: *"r,m" (y)*, appears to work, but simply
ignores alternatives after the first, as evidenced by: *"m,r" (y)*. Have
these issues been resolved or under consideration in current revisions?

LLVM currently always spills "rm" constraints in order to simplify the
handling of inline asm in the backend (you can ask on llvmdev if you want
details). I don't know of any plans to fix this in the near future.

I apologize for the bold-type, hyperlinks, etc., in advance. I'm not sure

of the posting etiquette. The original stackoverflow question is more
concise.

We care more that you're asking a well-formed question than the details of
how it's formatted. :slight_smile:

-Eli