[llvm-dev] Inline ASM Question

Bill Wendling via llvm-dev llvm-dev at lists.llvm.org
Tue Apr 2 23:29:33 PDT 2019


The code below is triggering some weird behavior that's different from how
gcc treats this inline asm. Clang keeps the original type of "loc" as
"bool", which generates an "i1 true" after inlining. So far so good.
However, during ISEL, the "true" is converted to a signed integer. So when
it's evaluated, the result is this:


    .quad (42+(-1))-.Ltmp0


(notice the "-1"). GCC emits a positive one instead:


    .quad 42 + 1 - .Ltmp0


I'm not sure where the problem lies. Should the inline asm promote the "i1"
to "i32" during ISEL? Should it be promoted during inlining? Is there a
situation where we require the value to be "i1"?


-bw


typedef _Bool bool;


static inline

__attribute__((__always_inline__))

bool bar(bool loc) {

        asm(".quad 42 + %c0 - .\n\t" : : "i" (loc));

        return 1;

}


int foo(void) {

        return bar(1);

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190402/4fd82f5f/attachment.html>


More information about the llvm-dev mailing list