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: [email protected]
Reporter: [email protected]
CC: [email protected]
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._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs