https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91109
--- Comment #14 from Bernd Edlinger <bernd.edlinger at hotmail dot de> --- I can reproduce with trunk: arm-linux-gnueabihf-gcc -S -O2 -mthumb -flto -fno-use-linker-plugin 20040709-1.c but not with -O3 -g, neither with gcc-9 and my fix applied. Nevertheless it is quite obvious that the second patch is needed to handle the case when rematerialized instructions have scratches, but nothing needs to be spilled so the loop need to continue with lra_assign instead of lra_spill.