This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80372] New: non-optimal handling of copying a std::complex<double>
- From: "noone at turm-lahnstein dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 09 Apr 2017 05:15:16 +0000
- Subject: [Bug c++/80372] New: non-optimal handling of copying a std::complex<double>
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80372
Bug ID: 80372
Summary: non-optimal handling of copying a std::complex<double>
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: noone@turm-lahnstein.de
Target Milestone: ---
While copying a std::complex<double> from a memory location to another, four
movsd operations are used. However it is possible to use two movups, which are
faster (at least on some hardware) and need less memory (36 bytes for
movsd-version, but only 16 the the movups-version).
Consider the following example:
#include <complex>
void get(std::complex<double> *res){
res[1]=res[0];
}
is compiled to:
movsd (%rdi), %xmm0
movsd %xmm0, 16(%rdi)
movsd 8(%rdi), %xmm0
movsd %xmm0, 24(%rdi)
ret
but could be:
movups (%rdi), %xmm0
movups %xmm0, 16(%rdi)
ret
That is in fact, what clang and icc17 do.