https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80155
--- Comment #23 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 7 Apr 2017, thopre01 at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80155 > > --- Comment #22 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> --- > (In reply to Thomas Preud'homme from comment #21) > > > > I can see this behavior for Cortex-M0+ indeed but the results are different > > for Cortex-M7 for me: > > > > <with code hoisting> > > % arm-none-linux-gnueabi-gcc -S ~/cortex-m0plus_reproducer.c -O2 > > -mcpu=cortex-m7 -mthumb -fdump-tree-pre-details -fdump-tree-crited > > -fdump-tree-all -funroll-all-loops > > > > % grep push cortex-m0plus_reproducer.s > > push {r4, r5} > > > > > > <without code hoisting> > > % arm-none-linux-gnueabi-gcc -S ~/cortex-m0plus_reproducer.c -O2 > > -mcpu=cortex-m7 -mthumb -fdump-tree-pre-details -fdump-tree-crited > > -fdump-tree-all -funroll-all-loops -fno-code-hoisting > > > > % grep push cortex-m0plus_reproducer.s > > push {r4} > > > > Would you mind checking again? > > btw, this toolchain was built on 2017-04-04 in case that's the issue. Ok, I can reproduce it now. With the proposed patch to fix the other case it regresses with -fno-code-hoisting though (comment #9 plus fix). Note that code-hosting is simply doing it's job here, hoisting common code out of a switch.