https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96780
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Yes, from a very quick test, it does exactly what I want. As discussed on IRC, we might not want to do this folding at -O0 (although I'd personally be happy with it unconditionally).