[llvm-bugs] [Bug 42179] New: Supoptimal code for float/double abs pattern with -Ofast
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jun 7 07:57:23 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42179
Bug ID: 42179
Summary: Supoptimal code for float/double abs pattern with
-Ofast
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
Compiled with flags -Ofast -march=haswell
Pretty common ABS code..
float absfast(float value)
{
if (value >= 0.0f)
return value;
else
return -value;
}
Instead of
absfast:
vandps xmm0, xmm0, XMMWORD PTR .LC0[rip]
ret
We have
absfast: # @absfast
vbroadcastss xmm1, dword ptr [rip + .LCPI0_0] # xmm1 =
[-0.0E+0,-0.0E+0,-0.0E+0,-0.0E+0]
vxorps xmm1, xmm0, xmm1
vxorps xmm2, xmm2, xmm2
vcmpltss xmm2, xmm0, xmm2
vblendvps xmm0, xmm0, xmm1, xmm2
ret
Which is very slow.., see abs8
test description absolute operations ratio with
number time per second test0
0 "float fabs" 0.00 sec 24729.52 M 1.00
1 "float fabsf" 0.00 sec 24798.51 M 1.00
2 "float std abs" 0.00 sec 24744.82 M 1.00
3 "float abs1" 0.00 sec 24806.20 M 1.00
4 "float abs2" 0.00 sec 24744.82 M 1.00
5 "float abs6" 0.00 sec 24867.89 M 0.99
6 "float abs7" 0.01 sec 8431.70 M 2.93
7 "float abs8" 0.21 sec 373.54 M 66.20
8 "float abs9" 0.00 sec 24737.17 M 1.00
Total absolute time for float absolute value: 0.25 sec
--
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/20190607/5a05eb2e/attachment.html>
More information about the llvm-bugs
mailing list