https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108552
--- Comment #41 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Linus Torvalds from comment #31) > (In reply to Richard Biener from comment #26) > > > > Now, in principle we should have applied store-motion and not only PRE which > > would have avoided the issue, not tricking the RA into reloading the value > > from where we store it in the loop, but the kernel uses -fno-tree-loop-im, > > preventing that. If you enable that you'd get > > Note that we use -fno-tree-loop-im only for the GCOV case, and because of > another problem with code generation with gcov. See > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69702 > > and the fix for the excessive stack use was to disable that compiler option. > See > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/ > ?id=c87bf431448b404a6ef5fbabd74c0e3e42157a7f > > for the kernel commit message. Yes, I remember. So another option would be to add -fno-tree-pre to that mix which should avoid hoisting the load out of the loop.