This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Decrease # of update_stmt calls from alias analysis
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Michael Matz <matz at suse dot de>, Andrew MacLeod <amacleod at redhat dot com>, dberlin at dberlin dot org, dnovillo at redhat dot com
- Date: Wed, 1 Mar 2006 11:23:19 +0100
- Subject: [patch] Decrease # of update_stmt calls from alias analysis
- References: <20060227170004.GA9176@atrey.karlin.mff.cuni.cz> <1141149999.10812.362.camel@localhost.localdomain> <Pine.LNX.4.58.0602281908051.20821@wotan.suse.de> <1141154104.6054.27.camel@localhost>
Hello,
the most update_stmt calls (113845, i.e., 67% for combine.i on -O2) in gcc come from
alias analysis -- it is called six times and it rescans all statements.
This patch at least makes us avoid rescanning statements without virtual
operands (whose operands are obviously unaffected by alias analysis).
This decreases the number of calls to 46525. This unfortunately does
not help my original purpose of the investigation (to decrease the cost
for building virtual operands), but cannot be a bad thing anyway.
Bootstrapped & regtested on i686.
Zdenek
* tree-flow.h (struct stmt_ann_d): Add has_virtual_ops field.
* tree-ssa-structalias.c (find_func_aliases): Only mark
the statements that may have virtual operands for rescanning.
* tree-ssa-operands.c (build_ssa_operands, get_expr_operands,
get_asm_expr_operands, get_call_expr_operands): Set has_virtual_ops
field.
Index: tree-flow.h
===================================================================
*** tree-flow.h (revision 111394)
--- tree-flow.h (working copy)
*************** struct stmt_ann_d GTY(())
*** 259,264 ****
--- 259,267 ----
need to be scanned again). */
unsigned modified : 1;
+ /* Nonzero if the statement should have virtual operands. */
+ unsigned has_virtual_ops : 1;
+
/* Nonzero if the statement makes references to volatile storage. */
unsigned has_volatile_ops : 1;
Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c (revision 111394)
--- tree-ssa-structalias.c (working copy)
*************** find_func_aliases (tree origt)
*** 3497,3504 ****
/* After promoting variables and computing aliasing we will
need to re-scan most statements. FIXME: Try to minimize the
number of statements re-scanned. It's not really necessary to
! re-scan *all* statements. */
! mark_stmt_modified (origt);
VEC_free (ce_s, heap, rhsc);
VEC_free (ce_s, heap, lhsc);
}
--- 3497,3506 ----
/* After promoting variables and computing aliasing we will
need to re-scan most statements. FIXME: Try to minimize the
number of statements re-scanned. It's not really necessary to
! re-scan *all* statements. */
! if (TREE_CODE (origt) != PHI_NODE
! && stmt_ann (origt)->has_virtual_ops)
! mark_stmt_modified (origt);
VEC_free (ce_s, heap, rhsc);
VEC_free (ce_s, heap, lhsc);
}
Index: tree-ssa-operands.c
===================================================================
*** tree-ssa-operands.c (revision 111394)
--- tree-ssa-operands.c (working copy)
*************** build_ssa_operands (tree stmt)
*** 827,834 ****
stmt_ann_t ann = get_stmt_ann (stmt);
/* Initially assume that the statement has no volatile operands. */
! if (ann)
! ann->has_volatile_ops = false;
start_ssa_stmt_operands ();
--- 827,834 ----
stmt_ann_t ann = get_stmt_ann (stmt);
/* Initially assume that the statement has no volatile operands. */
! ann->has_volatile_ops = false;
! ann->has_virtual_ops = false;
start_ssa_stmt_operands ();
*************** get_expr_operands (tree stmt, tree *expr
*** 1104,1109 ****
--- 1105,1114 ----
case RESULT_DECL:
{
subvar_t svars;
+
+ if (!(flags & opf_no_vops)
+ && !is_gimple_reg (expr))
+ s_ann->has_virtual_ops = true;
/* Add the subvars for a variable if it has subvars, to DEFS
or USES. Otherwise, add the variable itself. Whether it
*************** get_expr_operands (tree stmt, tree *expr
*** 1127,1137 ****
--- 1132,1146 ----
case ALIGN_INDIRECT_REF:
case INDIRECT_REF:
+ if (!(flags & opf_no_vops))
+ s_ann->has_virtual_ops = true;
get_indirect_ref_operands (stmt, expr, flags, NULL_TREE,
0, -1, true);
return;
case TARGET_MEM_REF:
+ if (!(flags & opf_no_vops))
+ s_ann->has_virtual_ops = true;
get_tmr_operands (stmt, expr, flags);
return;
*************** get_expr_operands (tree stmt, tree *expr
*** 1154,1159 ****
--- 1163,1170 ----
HOST_WIDE_INT offset, size, maxsize;
bool none = true;
+ if (!(flags & opf_no_vops))
+ s_ann->has_virtual_ops = true;
/* This component reference becomes an access to all of the
subvariables it can touch, if we can determine that, but
*NOT* the real one. If we can't determine which fields we
*************** get_asm_expr_operands (tree stmt)
*** 1393,1398 ****
--- 1404,1411 ----
{
unsigned i;
bitmap_iterator bi;
+
+ s_ann->has_virtual_ops = true;
/* Clobber all call-clobbered variables (or .GLOBAL_VAR if we
decided to group them). */
*************** get_call_expr_operands (tree stmt, tree
*** 1583,1588 ****
--- 1596,1604 ----
tree op;
int call_flags = call_expr_flags (expr);
+ if (!(call_flags & (ECF_NOVOPS | ECF_CONST)))
+ stmt_ann (stmt)->has_virtual_ops = true;
+
/* If aliases have been computed already, add V_MAY_DEF or V_USE
operands for all the symbols that have been found to be
call-clobbered.