[LLVMdev] [PATCH] x86: disambiguate unqualified btr, bts

Tim Northover t.p.northover at gmail.com
Sun Jul 14 02:29:22 PDT 2013

> The patch _replaces_ btrl instructions with btr
> instructions, for seemingly good reason.  What is your opinion on the
> issue?

Mine is it would be a sympathetic reason if correct, but not good if
the instructions shouldn't exist in the first place. However:

(From the commit message):
>     The inline assembly for the bit operations has been changed to remove
>     explicit sizing hints on the instructions, so the assembler will pick
>     the appropriate instruction forms depending on the architecture and
>     the context.

It doesn't do this, as far as I can tell. I cannot make the unsuffixed
versions do anything except an 'l' access in either gas or gcc,
regardless of architecture, pointer size or anything else.

What the code actually does is produce "btsl $imm, addr" if 0 <= imm
<=31 (at compile-time) and "btsl %eax, addr" otherwise, which works
even for 64-bit types (by Stephen's analysis), but involves an extra
"movl $imm, %eax".

>From the commit message, it seems like they *do* intend it to produce
"btslq $imm, addr" where possible and might well be open to fixing
this as a bug (that just happens to help Linux compile with Clang)
rather than purely for toolchain compatibility.

That said, it's not clear how to enable both forms to be generated
easily from inline asm, but I'm not an expert.


More information about the llvm-dev mailing list