[LLVMbugs] [Bug 20197] New: Inline asm constraint alternatives ignored
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jul 3 07:40:05 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20197
Bug ID: 20197
Summary: Inline asm constraint alternatives ignored
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: benny.kra at gmail.com
CC: echristo at gmail.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
When multiple alternatives in an inline asm constraint are given we ignore all
of them but the most "general". This gives nasty artifacts in the code.
int bsr(unsigned v) {
int ret;
__asm__("bsr %1, %0" : "=&r"(ret) : "rm"(v) : "cc");
return ret;
}
$ clang -O3 -S -o - t.c
bsr:
movl %edi, -4(%rsp)
#APP
bsrl -4(%rsp), %eax
#NO_APP
retq
The spilling is totally unnecessary. GCC gets this one right. On 32 bit x86
it's even worse:
$ clang -O3 -S -o - t.c -m32
bsr:
pushl %eax
movl 8(%esp), %eax
movl %eax, (%esp)
#APP
bsrl (%esp), %eax
#NO_APP
popl %edx
retl
GCC knows a better way:
$ gcc-4.8 -O3 -S -o - t.c -m32
bsr:
#APP
bsr 4(%esp), %eax
#NO_APP
ret
The constraint "g" is just as bad, being translated into "imr" internally.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140703/3477a9fb/attachment.html>
More information about the llvm-bugs
mailing list