Index: tree-ssa-pre.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v retrieving revision 1.1.4.94 diff -u -3 -p -r1.1.4.94 tree-ssa-pre.c --- tree-ssa-pre.c 24 Oct 2003 07:41:31 -0000 1.1.4.94 +++ tree-ssa-pre.c 29 Oct 2003 15:03:21 -0000 @@ -323,7 +323,8 @@ struct expr_info /* Cache of expressions generated for given phi operand, to avoid recomputation and wasting memory. */ -tree *phi_pred_cache; +static tree *phi_pred_cache; +static int n_phi_preds; /* Trying to lookup ephi pred operand indexes takes forever on graphs that have high connectivity because it's an O(n) linked list @@ -1193,7 +1224,6 @@ /* Make a copy of Z as it would look in BB j, using the PHIs in BB. */ static tree subst_phis (struct expr_info *ei, tree Z, basic_block j, basic_block bb) { tree stmt_copy; - if (phi_pred_cache[j->index] != NULL_TREE) @@ -1200,6 +1232,12 @@ + + /* Return the cached version, if we have one. */ + if (j->index < n_phi_preds + && phi_pred_cache[j->index] != NULL_TREE) return phi_pred_cache[j->index]; + + /* Otherwise, generate a new expression. */ pre_stats.exprs_generated++; stmt_copy = unshare_expr (Z); create_stmt_ann (stmt_copy); modify_stmt (stmt_copy); get_stmt_operands (stmt_copy); @@ -1210,1 +1248,0 @@ - phi_pred_cache[j->index] = stmt_copy; @@ -1211,3 +1273,6 @@ + + if (j->index < n_phi_preds) + phi_pred_cache[j->index] = stmt_copy; return stmt_copy; } @@ -3045,6 +3129,7 @@ pre_expression (struct expr_info *slot, bitmap_clear (created_phi_preds); ephi_pindex_htab = htab_create (500, ephi_pindex_hash, ephi_pindex_eq, free); phi_pred_cache = xcalloc (last_basic_block, sizeof (tree)); + n_phi_preds = last_basic_block; if (!expr_phi_insertion ((bitmap *)data, ei)) goto cleanup;