[llvm-bugs] [Bug 47794] New: missed optimization to use MOVS to copy arrays
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Oct 11 06:53:40 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47794
Bug ID: 47794
Summary: missed optimization to use MOVS to copy arrays
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: enhex0 at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
For example the following code generates `MOVSQ` with GCC, and `call memcpy`
with Clang:
https://godbolt.org/z/15bPh5
```
#include <iostream>
#include <array>
#include <random>
using namespace std;
random_device rd;
int main()
{
std::array<char, 512> a;
std::array<char, 512> b;
for(auto& e : a) { // prevent optimizing away
e = rd();
}
for(int i=0; i < a.size(); ++i) { // copy
b[i] = a[i];
}
for(auto const& e : b) { // prevent optimizing away
cout << e;
}
}
```
It seems that using MOVSQ is about 4-5 times faster:
Clang: https://quick-bench.com/q/LK5SmbOYZc8T-Kvy48jsf1tAL9w
GCC: https://quick-bench.com/q/qG8ApWJV7Ad-ghub2of6C_WWMYM
--
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/20201011/bae3eea4/attachment.html>
More information about the llvm-bugs
mailing list