From patchwork Wed Jun 23 18:53:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 0003-Improve-VBEout-computation.patch From: Maxim Kuvyrkov X-Patchwork-Id: 56702 Message-Id: <4C225847.1020900@codesourcery.com> To: Jeff Law Cc: gcc-patches Date: Wed, 23 Jun 2010 22:53:59 +0400 On 6/22/10 4:02 PM, Maxim Kuvyrkov wrote: ... > I'll post another version of the patch in a couple of days when I finish > reworking other pieces of improvements to hoisting. Updated version. OK to check in? Thanks, diff --git a/gcc/gcse.c b/gcc/gcse.c index 103f0e0..22576ca 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -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. */