https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71455
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- I think the patches for the performance issue were not too invasive so backporting them should be possible. You can identify them by searching bugzilla for "expand" slowness or by bisecting SVN revisions to find them (IIRC there were multiple issues, not sure which one your testcase runs into).