[cfe-dev] Inline assembly - multiple constraints and reloads.

Eli Friedman eli.friedman at gmail.com
Wed Jun 5 20:15:42 PDT 2013


On Wed, Jun 5, 2013 at 2:50 PM, Brett Hale <brettyhale at gmail.com> wrote:

> I recently submitted this question to stackoverflow<http://stackoverflow.com/questions/16850309/clang-llvm-inline-assembly-multiple-constraints-with-useless-spills-reload>,
> 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. :)

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130605/b5072b97/attachment.html>


More information about the cfe-dev mailing list