https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46590
--- Comment #51 from Richard Biener <rguenth at gcc dot gnu.org> --- Alternative patch, the first one doesn't seem to work (probably all_blocks is sometimes NULL, will debug). Index: gcc/df.h =================================================================== --- gcc/df.h (revision 270053) +++ gcc/df.h (working copy) @@ -1023,6 +1023,7 @@ extern void df_lr_verify_transfer_functi extern void df_live_verify_transfer_functions (void); extern void df_live_add_problem (void); extern void df_live_set_all_dirty (void); +extern void df_live_set_loop_dirty (struct loop *); extern void df_chain_add_problem (unsigned int); extern void df_word_lr_add_problem (void); extern bool df_word_lr_mark_ref (df_ref, bool, bitmap); Index: gcc/df-problems.c =================================================================== --- gcc/df-problems.c (revision 270053) +++ gcc/df-problems.c (working copy) @@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. #include "valtrack.h" #include "dumpfile.h" #include "rtl-iter.h" +#include "cfgloop.h" /* Note that turning REG_DEAD_DEBUGGING on will cause gcc.c-torture/unsorted/dump-noaddr.c to fail because it prints @@ -1774,6 +1775,18 @@ df_live_set_all_dirty (void) } +/* Set all of the blocks of LOOP as dirty. This needs to be done if this + problem is added after all of the insns have been scanned. */ + +void +df_live_set_loop_dirty (struct loop *loop) +{ + basic_block *bbs = get_loop_body (loop); + for (unsigned i = 0; i < loop->num_nodes; ++i) + bitmap_set_bit (df_live->out_of_date_transfer_functions, bbs[i]->index); +} + + /* Verify that all of the lr related info is consistent and correct. */ Index: gcc/loop-invariant.c =================================================================== --- gcc/loop-invariant.c (revision 270053) +++ gcc/loop-invariant.c (working copy) @@ -685,7 +685,7 @@ find_defs (struct loop *loop) df_process_deferred_rescans (); df_chain_add_problem (DF_UD_CHAIN); df_live_add_problem (); - df_live_set_all_dirty (); + df_live_set_loop_dirty (loop); df_set_flags (DF_RD_PRUNE_DEAD_DEFS); df_analyze_loop (loop); check_invariant_table_size ();