[LLVMbugs] [Bug 23575] New: [aarch64][inline assembler] Clang should turn add into sub when necessary.
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue May 19 08:17:38 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23575
Bug ID: 23575
Summary: [aarch64][inline assembler] Clang should turn add into
sub when necessary.
Product: clang
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jacob.bramley at arm.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
(Using Clang 3.6 as packaged in Ubuntu 14.04.)
GNU as will assemble `add w0, w0, #-1` into `sub w0, w0, #1`. This feature is
very useful, and indeed it is the only reasonable use for the "J" constraint.
Here's a simple use-case:
----
int add(int a, int b) {
int result;
__asm__ __volatile__ (
"add %w[result], %w[a], %w[b]\n\t"
: [result]"=&r" (result), [a]"=r" (a)
: [b]"IJr" (b)
);
return result;
}
int test(int a) {
return add(a, -1); // Should be inlined as `sub w0, w0, #1`.
}
----
test.cc:7:5: error: expected compatible register, symbol or integer in range
[0, 4095]
"add %w[result], %w[a], %w[b]\n\t"
^
<inline asm>:1:14: note: instantiated into assembly here
add w0, w8, #-1
----
We found this problem trying to compile Google V8 using Clang.
I think this is related to bug 20456, but it seems to be slightly different.
--
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/20150519/5503a7e3/attachment.html>
More information about the llvm-bugs
mailing list