After some discussion in the gcc mailing list, one of the developers there declared it a bug in gcc - "asm volatile" statements can move across normal code, but not across other asm volatiles, volatile memory accesses, or other observable behaviour. He filed an upstream gcc bug, and also posted a patch:
The patch is very simple, and should be directly applicable to any version of gcc as the relevant code has not changed in years.
Hopefully the gcc-arm-embedded folk will therefore be able to include it in all their currently open toolchain branches, to be included in their next releases.
After some discussion in the gcc mailing list, one of the developers there declared it a bug in gcc - "asm volatile" statements can move across normal code, but not across other asm volatiles, volatile memory accesses, or other observable behaviour. He filed an upstream gcc bug, and also posted a patch:
<https:/ /gcc.gnu. org/bugzilla/ show_bug. cgi?id= 82602>
The patch is very simple, and should be directly applicable to any version of gcc as the relevant code has not changed in years.
Hopefully the gcc-arm-embedded folk will therefore be able to include it in all their currently open toolchain branches, to be included in their next releases.