From: Richard Biener Date: Mon, 16 Nov 2020 13:25:56 +0000 (+0100) Subject: further optimize non-store-motion LIM X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d1746388db6481d87f5a801d79b17566fc6888da;p=gcc.git further optimize non-store-motion LIM This removes useless work from LIM when store-motion is disabled. 2020-11-16 Richard Biener * tree-ssa-loop-im.c (analyze_memory_references): Add store_motion parameter and elide unnecessary work. (tree_ssa_lim_initialize): Likewise. (loop_invariant_motion_in_fun): Pass down store_motion. --- diff --git a/gcc/tree-ssa-loop-im.c b/gcc/tree-ssa-loop-im.c index 3c7412737f0..92e5a8dd774 100644 --- a/gcc/tree-ssa-loop-im.c +++ b/gcc/tree-ssa-loop-im.c @@ -1622,7 +1622,7 @@ sort_locs_in_loop_postorder_cmp (const void *loc1_, const void *loc2_, /* Gathers memory references in loops. */ static void -analyze_memory_references (void) +analyze_memory_references (bool store_motion) { gimple_stmt_iterator bsi; basic_block bb, *bbs; @@ -1665,6 +1665,9 @@ analyze_memory_references (void) free (bbs); + if (!store_motion) + return; + /* Propagate the information about accessed memory references up the loop hierarchy. */ FOR_EACH_LOOP (loop, LI_FROM_INNERMOST) @@ -3010,7 +3013,7 @@ fill_always_executed_in (void) /* Compute the global information needed by the loop invariant motion pass. */ static void -tree_ssa_lim_initialize (void) +tree_ssa_lim_initialize (bool store_motion) { class loop *loop; unsigned i; @@ -3032,8 +3035,12 @@ tree_ssa_lim_initialize (void) memory_accesses.refs_loaded_in_loop.quick_grow (number_of_loops (cfun)); memory_accesses.refs_stored_in_loop.create (number_of_loops (cfun)); memory_accesses.refs_stored_in_loop.quick_grow (number_of_loops (cfun)); - memory_accesses.all_refs_stored_in_loop.create (number_of_loops (cfun)); - memory_accesses.all_refs_stored_in_loop.quick_grow (number_of_loops (cfun)); + if (store_motion) + { + memory_accesses.all_refs_stored_in_loop.create (number_of_loops (cfun)); + memory_accesses.all_refs_stored_in_loop.quick_grow + (number_of_loops (cfun)); + } for (i = 0; i < number_of_loops (cfun); i++) { @@ -3041,8 +3048,9 @@ tree_ssa_lim_initialize (void) &lim_bitmap_obstack); bitmap_initialize (&memory_accesses.refs_stored_in_loop[i], &lim_bitmap_obstack); - bitmap_initialize (&memory_accesses.all_refs_stored_in_loop[i], - &lim_bitmap_obstack); + if (store_motion) + bitmap_initialize (&memory_accesses.all_refs_stored_in_loop[i], + &lim_bitmap_obstack); } memory_accesses.ttae_cache = NULL; @@ -3097,10 +3105,10 @@ loop_invariant_motion_in_fun (function *fun, bool store_motion) { unsigned int todo = 0; - tree_ssa_lim_initialize (); + tree_ssa_lim_initialize (store_motion); /* Gathers information about memory accesses in the loops. */ - analyze_memory_references (); + analyze_memory_references (store_motion); /* Fills ALWAYS_EXECUTED_IN information for basic blocks. */ fill_always_executed_in ();