[Bug libstdc++/69657] New: [6 Regression] abs() not inlined after including math.h
wdijkstr at arm dot com
gcc-bugzilla@gcc.gnu.org
Wed Feb 3 18:26:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69657
Bug ID: 69657
Summary: [6 Regression] abs() not inlined after including
math.h
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: wdijkstr at arm dot com
Target Milestone: ---
Since a recent C++ header change abs() no longer gets inlined if we include an
unrelated header before it.
#include <math.h>
#include <cstdlib>
int
wrap_abs (int x)
{
return abs (x) + std::abs(x);
}
Until recently GCC6 with -O2 -S produced for AArch64:
_Z8wrap_absi:
cmp w0, wzr
csneg w0, w0, w0, ge
lsl w0, w0, 1
ret
However trunk GCC6 now emits:
_Z8wrap_absi:
stp x29, x30, [sp, -16]!
add x29, sp, 0
bl abs
lsl w0, w0, 1
ldp x29, x30, [sp], 16
This may result in significant slowdowns as it adds a call and PLT indirection
to execute a 3-instruction function. There might be other builtin functions
that are affected in a similar way.
More information about the Gcc-bugs
mailing list