[llvm-bugs] [Bug 38751] New: Missed optimization in 16-bit __builtin_add_overflow on aarch64
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 28 18:24:26 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38751
Bug ID: 38751
Summary: Missed optimization in 16-bit __builtin_add_overflow
on aarch64
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: AArch64
Assignee: unassignedbugs at nondot.org
Reporter: tblodt at icloud.com
CC: llvm-bugs at lists.llvm.org
The following C function generates this code on aarch64 with -O3:
void g(int a, int b, int *c, int *o, int *v) {
*o = __builtin_add_overflow((int16_t) a, (int16_t) b, (int16_t *) c);
}
sxth w8, w0
add w8, w8, w1, sxth
sxth w9, w8
cmp w9, w8
cset w9, ne
strh w8, [x2]
str w9, [x3]
ret
The sequence
sxth w9, w8
cmp w9, w8
can be rewritten as
cmp w8, w8, sxth
which is one instruction shorter and uses one less register. So the following
code should be generated instead:
sxth w8, w0
add w8, w8, w1, sxth
cmp w8, w8, sxth
str w8, [x2]
cset w8, ne
str w8, [x3]
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/20180829/a594f394/attachment.html>
More information about the llvm-bugs
mailing list