[Bug libstdc++/80335] perf of copying std::optional<trivial>
sgunderson at bigfoot dot com
gcc-bugzilla@gcc.gnu.org
Sat Jun 16 12:06:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80335
--- Comment #3 from sgunderson at bigfoot dot com ---
Appears to have been fixed in GCC 8, indeed.
#include <optional>
std::optional<long> func()
{
return 3;
}
GCC 7 (-O2) compiles to:
0: 48 89 f8 mov %rdi,%rax
3: c7 07 03 00 00 00 movl $0x3,(%rdi)
9: c6 47 04 01 movb $0x1,0x4(%rdi)
d: c3 retq
GCC 8 (-O2):
0: 48 b8 03 00 00 00 01 movabs $0x100000003,%rax
7: 00 00 00
a: c3 retq
This is an ABI break, but I'll happily take it. :-)
More information about the Gcc-bugs
mailing list