On Thu, 28 Oct 2021 at 08:11, ☂Josh Chia (謝任中) via Gcc-help <gcc-help@xxxxxxxxxxx> wrote: > > Under -O3 -std=c++17, the assembly code generated by gcc 11.2 for some > std::optional C++ code seems less optimal than I expect; it is writing the > content of optional<uint64_t> return values to both the stack and to the > RAX register. What am I missing? I was under the impression that return > values are put in RAX if they can fit. Why does gcc have to write the > return value to both the stack and RAX instead of just one of them? Can the > writing to the stack be avoided? Is this https://gcc.gnu.org/PR101326 ?