@@ -4171,8 +4171,16 @@ compute_code_hoist_vbeinout (void)
FOR_EACH_BB_REVERSE (bb)
{
if (bb->next_bb != EXIT_BLOCK_PTR)
- sbitmap_intersection_of_succs (hoist_vbeout[bb->index],
- hoist_vbein, bb->index);
+ {
+ sbitmap_intersection_of_succs (hoist_vbeout[bb->index],
+ hoist_vbein, bb->index);
+
+ /* One of the quirks of code hoisting algorithm in Muchnick
+ is that VBEout[BB] does not include expressions calculated
+ in BB itself and available at its end. Fix this. */
+ sbitmap_a_or_b (hoist_vbeout[bb->index],
+ hoist_vbeout[bb->index], comp[bb->index]);
+ }
changed |= sbitmap_a_or_b_and_c_cg (hoist_vbein[bb->index],
antloc[bb->index],
@@ -4184,7 +4192,17 @@ compute_code_hoist_vbeinout (void)
}
if (dump_file)
- fprintf (dump_file, "hoisting vbeinout computation: %d passes\n", passes);
+ {
+ fprintf (dump_file, "hoisting vbeinout computation: %d passes\n", passes);
+
+ FOR_EACH_BB (bb)
+ {
+ fprintf (dump_file, "vbein (%d): ", bb->index);
+ dump_sbitmap_file (dump_file, hoist_vbein[bb->index]);
+ fprintf (dump_file, "vbeout(%d): ", bb->index);
+ dump_sbitmap_file (dump_file, hoist_vbeout[bb->index]);
+ }
+ }
}
/* Top level routine to do the dataflow analysis needed by code hoisting. */
@@ -4298,6 +4316,11 @@ hoist_code (void)
if (TEST_BIT (hoist_vbeout[bb->index], i)
&& TEST_BIT (transpout[bb->index], i))
{
+ /* If an expression is computed in BB and is available at end of
+ BB, hoist all occurences dominated by BB to BB. */
+ if (TEST_BIT (comp[bb->index], i))
+ hoistable++;
+
/* We've found a potentially hoistable expression, now
we look at every block BB dominates to see if it
computes the expression. */