[LLVMbugs] [Bug 23460] New: integrated assembler rejects inlined add w9, w9, #-1 in AtomicIncrement
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri May 8 15:43:38 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23460
Bug ID: 23460
Summary: integrated assembler rejects inlined add w9,w9,#-1 in
AtomicIncrement
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: AArch64
Assignee: unassignedbugs at nondot.org
Reporter: chh at google.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
This test case shows that clang/llvm -target aarch64-lunix-android
failed to inline assembly code in NoBarrier_AtomicIncrement,
when the increment is -1.
There was no error when NoBarrier_AtomicIncrement is not inlined
or when -no-integrated-as is used.
$ cat a.cc
typedef int int32_t;
typedef unsigned int Atomic32;
#ifdef NO_INLINE
__attribute__((noinline))
#endif
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
Atomic32 result;
int32_t temp;
__asm__ __volatile__ (
"0: \n\t"
"ldxr %w[result], %[ptr] \n\t"
"add %w[result], %w[result], %w[increment]\n\t"
"stxr %w[temp], %w[result], %[ptr] \n\t"
"cbnz %w[temp], 0b \n\t"
: [result]"=&r" (result),
[temp]"=&r" (temp),
[ptr]"+Q" (*ptr)
: [increment]"IJr" (increment)
: "memory"
);
return result;
}
Atomic32* ptr;
void foo() {
NoBarrier_AtomicIncrement(ptr, 1);
NoBarrier_AtomicIncrement(ptr, -1);
}
$ clang++ -target aarch64-linux-android a.cc -S -O2 -o /tmp/x.O2.s
$.cc:12:49: error: expected compatible register, symbol or integer in range [0,
4095]
"ldxr %w[result], %[ptr] \n\t"
^
<inline asm>:3:14: note: instantiated into assembly here
add w9, w9, #-1
^
1 error generated.
$ clang++ -target aarch64-linux-android a.cc -S -O2 -no-integrated-as -o
/tmp/x.O2.s
$ clang++ -target aarch64-linux-android a.cc -S -O2 -DNO_INLINE -o /tmp/x.O2.s
This code pattern appears in Android Open Source
external/v8/src/base/atomicops_internals_arm64_gcc.h,
which is now compiled with -no-integrated-as flag.
When compiled with -no-integrated-as:
The instruction
add w9, w9, #-1
was correctly converted into
sub w9, w9, #0x1
When compiled with -DNO_INLINE, the embedded assembly code is:
0000000000000000 <_Z25NoBarrier_AtomicIncrementPVjj>:
0: 885f7c08 ldxr w8, [x0]
4: 0b010108 add w8, w8, w1
8: 88097c08 stxr w9, w8, [x0]
c: 35ffffa9 cbnz w9, 0 <_Z25NoBarrier_AtomicIncrementPVjj>
10: 2a0803e0 mov w0, w8
14: d65f03c0 ret
and -1 was passed in w1.
--
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/20150508/393fa3e5/attachment.html>
More information about the llvm-bugs
mailing list