https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120941

--- Comment #31 from Richard Biener <rguenth at gcc dot gnu.org> ---
-                      basic block if it is in a recursive call.  */
-                   || !recursive_call_p)
+                      basic block if it is in a recursive call or in
+                      a loop.  */
+                   || (!recursive_call_p
+                       && (load->bb->loop_father->latch
+                           == EXIT_BLOCK_PTR_FOR_FN (cfun))
+                       && (bb->loop_father->latch
+                           == EXIT_BLOCK_PTR_FOR_FN (cfun))))

"in a loop" is better tested as loop_outer (load->bb->loop_father) != NULL,
but your test should work, too.

I think we can possibly allow the case of load->bb->loop_father ==
bb->loop_father, but that would be more forgiving than your fix.

I wonder if we can simply add a debug counter to the above place and
see to identify the (single?) problematic hoisting?

Reply via email to