[llvm-bugs] [Bug 43953] New: [SLP] Missed sum reduction of differences
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Nov 9 08:59:24 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=43953
Bug ID: 43953
Summary: [SLP] Missed sum reduction of differences
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: a.bataev at hotmail.com, dtemirbulatov at gmail.com,
llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com
Noticed in a from
https://devblogs.microsoft.com/cppblog/game-performance-improvements-in-visual-studio-2019-version-16-2/
While the original example does vectorize:
uint32_t TestVectorsEqual(float* Vec0, float* Vec1, float Tolerance = 1e7f)
{
float sum = 0.f;
for (int32_t Component = 0; Component < 4; Component++)
{
float Diff = Vec0[Component] - Vec1[Component];
sum += (Diff >= 0.0f) ? Diff : -Diff;
}
return (sum <= Tolerance) ? 1 : 0;
}
This simpler version fails for some reason (probably costs....):
uint32_t TestVectorsEqual_alt(float* __restrict Vec0, float* __restrict Vec1,
float Tolerance = 1e7f)
{
float sum = 0.f;
for (int32_t Component = 0; Component < 4; Component++)
{
float Diff = Vec0[Component] - Vec1[Component];
sum += Diff;
}
return (sum <= Tolerance) ? 1 : 0;
}
https://gcc.godbolt.org/z/hG7Ntp
--
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/20191109/7f3a2d64/attachment.html>
More information about the llvm-bugs
mailing list