https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94086
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The testcase in comment #0 in GCC11+ GCC can optimize it to just a move followed by a return. Note the optimization only happens on the RTL level even. I have not looked into what allowed this to be optimized yet.