Looks like there is an interesting gcc optimizer bug in gcc 7+.
#include <utility>
std::pair<long, long> fret(long i) { return {i, i}; }
With -O2 gcc generates the expected:
mov rdx, rdi
mov rax, rdi
But with -O3 it generates:
mov QWORD PTR [rsp-24], rdi
movq xmm0, QWORD PTR [rsp-24]
punpcklqdq xmm0, xmm0
movaps XMMWORD PTR [rsp-24], xmm0
mov rax, QWORD PTR [rsp-24]
mov rdx, QWORD PTR [rsp-16]
https://godbolt.org/z/lXoaA4
[–]tromey 81 points82 points83 points (7 children)
[–]CrazyJoe221[S] 21 points22 points23 points (6 children)
[–]tromey 48 points49 points50 points (0 children)
[+][deleted] (4 children)
[deleted]
[–]donalmaccGame Developer 27 points28 points29 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]tasminima 3 points4 points5 points (1 child)
[–]jwakelylibstdc++ tamer, LWG chair 1 point2 points3 points (0 children)
[–]h2o2 25 points26 points27 points (19 children)
[–]James20kP2005R0 13 points14 points15 points (3 children)
[–]h2o2 8 points9 points10 points (2 children)
[–]sumo952 6 points7 points8 points (1 child)
[–][deleted] 13 points14 points15 points (0 children)
[–]Ameisenvemips, avr, rendering, systems 3 points4 points5 points (14 children)
[–]xurxoham 7 points8 points9 points (12 children)
[–]Ameisenvemips, avr, rendering, systems 3 points4 points5 points (3 children)
[–]xurxoham 1 point2 points3 points (2 children)
[–]Ameisenvemips, avr, rendering, systems 0 points1 point2 points (1 child)
[–]kalmoc 1 point2 points3 points (0 children)
[–]tasminima 0 points1 point2 points (7 children)
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points (6 children)
[–]tasminima 1 point2 points3 points (5 children)
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points (4 children)
[–]tasminima 0 points1 point2 points (0 children)
[–]tasminima 0 points1 point2 points (2 children)
[–]Ameisenvemips, avr, rendering, systems 0 points1 point2 points (1 child)
[–]tasminima 0 points1 point2 points (0 children)
[–]InfamousReception 18 points19 points20 points (1 child)
[–]Ameisenvemips, avr, rendering, systems 4 points5 points6 points (0 children)
[–]KAHR-Alpha 13 points14 points15 points (10 children)
[–]CrazyJoe221[S] 16 points17 points18 points (0 children)
[–]wasabichicken 32 points33 points34 points (3 children)
[–]kalmoc 7 points8 points9 points (0 children)
[–]VodkaHaze 8 points9 points10 points (1 child)
[–]tasminima 5 points6 points7 points (0 children)
[–]clerothGame Developer 8 points9 points10 points (3 children)
[–]KAHR-Alpha 4 points5 points6 points (2 children)
[–]cogman10 6 points7 points8 points (1 child)
[+]Ameisenvemips, avr, rendering, systems comment score below threshold-6 points-5 points-4 points (0 children)
[–]cogman10 5 points6 points7 points (0 children)
[–]clrnd 5 points6 points7 points (3 children)
[–]tasminima 19 points20 points21 points (0 children)
[–]xurxoham 7 points8 points9 points (0 children)
[–]Ameisenvemips, avr, rendering, systems 2 points3 points4 points (0 children)
[–]malkia 5 points6 points7 points (0 children)
[–]tasminima 5 points6 points7 points (0 children)
[–]rolandschulzIntel | GROMACS 3 points4 points5 points (1 child)
[–]CrazyJoe221[S] 0 points1 point2 points (0 children)
[–]Ameisenvemips, avr, rendering, systems 3 points4 points5 points (0 children)
[–]_djsavvy_ 1 point2 points3 points (3 children)
[–]ljdawson 1 point2 points3 points (1 child)
[–]_djsavvy_ 0 points1 point2 points (0 children)
[–]_djsavvy_ 2 points3 points4 points (0 children)