[llvm-bugs] [Bug 44153] New: copysign(x, signbit(x) ? +1.f : -1.f) folding
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 26 12:57:22 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44153
Bug ID: 44153
Summary: copysign(x, signbit(x) ? +1.f : -1.f) folding
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Keywords: code-quality
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: nok.raven at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, spatel+llvm at rotateright.com
There is a problem with replacing boost's changesign:
#include <boost/math/special_functions/sign.hpp>
float changesign_boost(float x) {
return boost::math::changesign(x);
}
#include <cmath>
float changesign_std(float x) {
bool isneg = std::signbit(x);
return std::copysign(x, isneg ? +1.f : -1.f);
}
changesign_boost(float):
xorps xmm0, xmmword ptr [rip + .LCPI0_0]
ret
changesign_std(float):
movd eax, xmm0
xor ecx, ecx
test eax, eax
sets cl
pand xmm0, xmmword ptr [rip + .LCPI1_0]
movd xmm1, dword ptr [4*rcx + .LCPI1_1]
pand xmm1, xmmword ptr [rip + .LCPI1_2]
por xmm0, xmm1
ret
https://godbolt.org/z/AN2VfR
--
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/20191126/a9e3a2d7/attachment.html>
More information about the llvm-bugs
mailing list