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: unassignedb...@nondot.org
Reporter: nruslan_de...@yahoo.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs