https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39326
--- Comment #60 from Richard Biener <rguenth at gcc dot gnu.org> --- PRE is all find_base_term exploding ... The LIM case is all store_motion () which is quadratic and the only user of the quadratic in memory all_refs_stored_in_loop. The latter would be reasonably easy to fix by iterating. The former is more difficult to fix, we'd need to rewrite SM to work inner-to-outer loops somehow. But that's certainly doable. Gating store-motion on optimize > 1 is possible as well (it also has the bad side-effect of increasing register pressure by introducing IVs).