[llvm-bugs] [Bug 36811] New: Inline assembly input operand inefficiency
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Mar 19 19:42:49 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=36811
Bug ID: 36811
Summary: Inline assembly input operand inefficiency
Product: libraries
Version: 6.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: nruslan_devel at yahoo.com
CC: llvm-bugs at lists.llvm.org
I have noticed that whenever "mr" is specified for an assembly input operand
which may accept both memory and register, clang/llvm does not seem to generate
efficient code.
(-O2 is used for all examples)
For example,
1.
unsigned long func(unsigned long x)
{
unsigned long r;
asm ("bsf %1, %0"
: "=r" (r)
: "mr" (x)
: "cc");
return r;
}
generates code which unnecessarily moves %rdi to memory
func: # @func
.cfi_startproc
# %bb.0:
movq %rdi, -8(%rsp)
#APP
bsfq -8(%rsp), %rax
#NO_APP
retq
2. whereas, if we change "mr" to simply "r" (for x)
we get optimal code
func: # @func
.cfi_startproc
# %bb.0:
#APP
bsfq %rdi, %rax
#NO_APP
retq
3. gcc generates optimal code in both cases
func:
.LFB0:
.cfi_startproc
#APP
# 4 "1.c" 1
bsf %rdi, %rax
# 0 "" 2
#NO_APP
ret
--
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/20180320/8e9e467a/attachment.html>
More information about the llvm-bugs
mailing list