From d630245f9d4584bd3ecb2192f8e2ba05e1db77ba Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Fri, 7 Sep 2012 10:23:06 +0000 Subject: [PATCH] bitmap.c (bitmap_last_set_bit): Rewrite to return the correct bit. * bitmap.c (bitmap_last_set_bit): Rewrite to return the correct bit. * graphite.c (print_global_statistics): Use EDGE_COUNT instead of VEC_length. (print_graphite_scop_statistics): Likewise. * graphite-scop-detection.c (get_bb_type): Use single_succ_p. (print_graphite_scop_statistics): Use EDGE_COUNT, not VEC_length. (canonicalize_loop_closed_ssa): Use single_pred_p. * alias.c (reg_seen): Make this an sbitmap. (record_set, init_alias_analysis): Update. * tree-ssa-coalesce.c (ssa_conflicts_dump): Fix dumping. From-SVN: r191063 --- gcc/ChangeLog | 16 ++++++++++++++++ gcc/alias.c | 18 +++++++++--------- gcc/bitmap.c | 31 +++++++++++-------------------- gcc/graphite-scop-detection.c | 10 ++++------ gcc/graphite.c | 4 ++-- gcc/tree-ssa-coalesce.c | 4 ++-- 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e3cf363a45..b6456048a7d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2012-09-07 Steven Bosscher + + * bitmap.c (bitmap_last_set_bit): Rewrite to return the correct bit. + + * graphite.c (print_global_statistics): Use EDGE_COUNT instead + of VEC_length. + (print_graphite_scop_statistics): Likewise. + * graphite-scop-detection.c (get_bb_type): Use single_succ_p. + (print_graphite_scop_statistics): Use EDGE_COUNT, not VEC_length. + (canonicalize_loop_closed_ssa): Use single_pred_p. + + * alias.c (reg_seen): Make this an sbitmap. + (record_set, init_alias_analysis): Update. + + * tree-ssa-coalesce.c (ssa_conflicts_dump): Fix dumping. + 2012-09-07 Tom de Vries PR tree-optimization/53986 diff --git a/gcc/alias.c b/gcc/alias.c index b7182074c5d..1df3529e942 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1220,7 +1220,7 @@ find_base_value (rtx src) /* While scanning insns to find base values, reg_seen[N] is nonzero if register N has been set in this function. */ -static char *reg_seen; +static sbitmap reg_seen; static void record_set (rtx dest, const_rtx set, void *data ATTRIBUTE_UNUSED) @@ -1246,7 +1246,7 @@ record_set (rtx dest, const_rtx set, void *data ATTRIBUTE_UNUSED) { while (--n >= 0) { - reg_seen[regno + n] = 1; + SET_BIT (reg_seen, regno + n); new_reg_base_value[regno + n] = 0; } return; @@ -1267,12 +1267,12 @@ record_set (rtx dest, const_rtx set, void *data ATTRIBUTE_UNUSED) else { /* There's a REG_NOALIAS note against DEST. */ - if (reg_seen[regno]) + if (TEST_BIT (reg_seen, regno)) { new_reg_base_value[regno] = 0; return; } - reg_seen[regno] = 1; + SET_BIT (reg_seen, regno); new_reg_base_value[regno] = unique_base_value (unique_id++); return; } @@ -1328,10 +1328,10 @@ record_set (rtx dest, const_rtx set, void *data ATTRIBUTE_UNUSED) } /* If this is the first set of a register, record the value. */ else if ((regno >= FIRST_PSEUDO_REGISTER || ! fixed_regs[regno]) - && ! reg_seen[regno] && new_reg_base_value[regno] == 0) + && ! TEST_BIT (reg_seen, regno) && new_reg_base_value[regno] == 0) new_reg_base_value[regno] = find_base_value (src); - reg_seen[regno] = 1; + SET_BIT (reg_seen, regno); } /* Return REG_BASE_VALUE for REGNO. Selective scheduler uses this to avoid @@ -2789,7 +2789,7 @@ init_alias_analysis (void) VEC_safe_grow_cleared (rtx, gc, reg_base_value, maxreg); new_reg_base_value = XNEWVEC (rtx, maxreg); - reg_seen = XNEWVEC (char, maxreg); + reg_seen = sbitmap_alloc (maxreg); /* The basic idea is that each pass through this loop will use the "constant" information from the previous pass to propagate alias @@ -2834,7 +2834,7 @@ init_alias_analysis (void) memset (new_reg_base_value, 0, maxreg * sizeof (rtx)); /* Wipe the reg_seen array clean. */ - memset (reg_seen, 0, maxreg); + sbitmap_zero (reg_seen); /* Mark all hard registers which may contain an address. The stack, frame and argument pointers may contain an address. @@ -2957,7 +2957,7 @@ init_alias_analysis (void) /* Clean up. */ free (new_reg_base_value); new_reg_base_value = 0; - free (reg_seen); + sbitmap_free (reg_seen); reg_seen = 0; timevar_pop (TV_ALIAS_ANALYSIS); } diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 1a28788bc3e..63f0e099a05 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -837,33 +837,24 @@ bitmap_last_set_bit (const_bitmap a) gcc_unreachable (); found_bit: bit_no += ix * BITMAP_WORD_BITS; - - /* Binary search for the last set bit. */ #if GCC_VERSION >= 3004 gcc_assert (sizeof(long) == sizeof (word)); - bit_no += sizeof (long) * 8 - __builtin_ctzl (word); + bit_no += BITMAP_WORD_BITS - __builtin_clzl (word) - 1; #else -#if BITMAP_WORD_BITS > 64 -#error "Fill out the table." -#endif + /* Hopefully this is a twos-complement host... */ + BITMAP_WORD x = word; + x |= (x >> 1); + x |= (x >> 2); + x |= (x >> 4); + x |= (x >> 8); + x |= (x >> 16); #if BITMAP_WORD_BITS > 32 - if ((word & 0xffffffff00000000)) - word >>= 32, bit_no += 32; + x |= (x >> 32); #endif - if (word & 0xffff0000) - word >>= 16, bit_no += 16; - if (!(word & 0xff00)) - word >>= 8, bit_no += 8; - if (!(word & 0xf0)) - word >>= 4, bit_no += 4; - if (!(word & 12)) - word >>= 2, bit_no += 2; - if (!(word & 2)) - word >>= 1, bit_no += 1; + bit_no += bitmap_popcount (x) - 1; #endif - gcc_checking_assert (word & 1); - return bit_no; + return bit_no; } diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 408e6b2fb52..48bbae94dce 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -67,7 +67,7 @@ static gbb_type get_bb_type (basic_block bb, struct loop *last_loop) { VEC (basic_block, heap) *dom; - int nb_dom, nb_suc; + int nb_dom; struct loop *loop = bb->loop_father; /* Check, if we entry into a new loop. */ @@ -88,9 +88,7 @@ get_bb_type (basic_block bb, struct loop *last_loop) if (nb_dom == 0) return GBB_LAST; - nb_suc = VEC_length (edge, bb->succs); - - if (nb_dom == 1 && nb_suc == 1) + if (nb_dom == 1 && single_succ_p (bb)) return GBB_SIMPLE; return GBB_COND_HEADER; @@ -1114,7 +1112,7 @@ print_graphite_scop_statistics (FILE* file, scop_p scop) n_bbs++; n_p_bbs += bb->count; - if (VEC_length (edge, bb->succs) > 1) + if (EDGE_COUNT (bb->succs) > 1) { n_conditions++; n_p_conditions += bb->count; @@ -1299,7 +1297,7 @@ canonicalize_loop_closed_ssa (loop_p loop) bb = e->dest; - if (VEC_length (edge, bb->preds) == 1) + if (single_pred_p (bb)) { e = split_block_after_labels (bb); make_close_phi_nodes_unique (e->src); diff --git a/gcc/graphite.c b/gcc/graphite.c index 04e1da29118..0eb1ca191d5 100644 --- a/gcc/graphite.c +++ b/gcc/graphite.c @@ -97,7 +97,7 @@ print_global_statistics (FILE* file) n_p_loops += bb->count; } - if (VEC_length (edge, bb->succs) > 1) + if (EDGE_COUNT (bb->succs) > 1) { n_conditions++; n_p_conditions += bb->count; @@ -149,7 +149,7 @@ print_graphite_scop_statistics (FILE* file, scop_p scop) n_bbs++; n_p_bbs += bb->count; - if (VEC_length (edge, bb->succs) > 1) + if (EDGE_COUNT (bb->succs) > 1) { n_conditions++; n_p_conditions += bb->count; diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 5d2ce38c5a6..6217825d1a6 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -626,10 +626,10 @@ ssa_conflicts_dump (FILE *file, ssa_conflicts_p ptr) fprintf (file, "\nConflict graph:\n"); - FOR_EACH_VEC_ELT (bitmap, ptr->conflicts, x, b); + FOR_EACH_VEC_ELT (bitmap, ptr->conflicts, x, b) if (b) { - fprintf (dump_file, "%d: ", x); + fprintf (file, "%d: ", x); dump_bitmap (file, b); } }