https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82602
--- Comment #9 from Segher Boessenkool <segher at gcc dot gnu.org> --- You cannot do that if you do not know what foo() does (it could for example contain another volatile asm). But yes, the code as written is not so great.