This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Remove N^2 update-ssa calls in IPA SRA
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jakub Jelinek <jakub at redhat dot com>, Martin Jambor <mjambor at suse dot de>
- Date: Mon, 17 Feb 2014 14:38:42 +0100 (CET)
- Subject: [PATCH] Remove N^2 update-ssa calls in IPA SRA
- Authentication-results: sourceware.org; auth=none
This removes the update_ssa call in ipa_modify_call_arguments by
keeping virtual SSA form up-to-date. It also avoids leaking
the virtual SSA name defined by the replaced call (and thus
keeping more than necessary memory live during early transforms).
Bootstrap and regtest in progress on x86_64-unknown-linux-gnu, ok
for trunk at this stage? (didn't come here with the compile-time
issue but with the leaked SSA name, both would improve the
general compile-time-hog/memory-usage regression)
Thanks,
Richard.
2014-02-17 Richard Biener <rguenther@suse.de>
* ipa-prop.c: Include stringpool.h and tree-ssanames.h.
(ipa_modify_call_arguments): Emit an argument load explicitely and
preserve virtual SSA form there and for the replacement call.
Do not update SSA form nor free dominance info.
Index: gcc/ipa-prop.c
===================================================================
*** gcc/ipa-prop.c (revision 207820)
--- gcc/ipa-prop.c (working copy)
*************** along with GCC; see the file COPYING3.
*** 57,62 ****
--- 57,64 ----
#include "tree-streamer.h"
#include "params.h"
#include "ipa-utils.h"
+ #include "stringpool.h"
+ #include "tree-ssanames.h"
/* Intermediate information about a parameter that is only useful during the
run of ipa_analyze_node and is not kept afterwards. */
*************** ipa_modify_call_arguments (struct cgraph
*** 3783,3800 ****
align = (misalign & -misalign);
if (align < TYPE_ALIGN (type))
type = build_aligned_type (type, align);
expr = fold_build2_loc (loc, MEM_REF, type, base, off);
}
else
{
expr = fold_build2_loc (loc, MEM_REF, adj->type, base, off);
expr = build_fold_addr_expr (expr);
}
-
- expr = force_gimple_operand_gsi (&gsi, expr,
- adj->by_ref
- || is_gimple_reg_type (adj->type),
- NULL, true, GSI_SAME_STMT);
vargs.quick_push (expr);
}
if (adj->op != IPA_PARM_OP_COPY && MAY_HAVE_DEBUG_STMTS)
--- 3785,3816 ----
align = (misalign & -misalign);
if (align < TYPE_ALIGN (type))
type = build_aligned_type (type, align);
+ base = force_gimple_operand_gsi (&gsi, base,
+ true, NULL, true, GSI_SAME_STMT);
expr = fold_build2_loc (loc, MEM_REF, type, base, off);
+ /* If expr is not a valid gimple call argument emit
+ a load into a temporary. */
+ if (is_gimple_reg_type (TREE_TYPE (expr)))
+ {
+ gimple tem = gimple_build_assign (NULL_TREE, expr);
+ if (gimple_in_ssa_p (cfun))
+ {
+ gimple_set_vuse (tem, gimple_vuse (stmt));
+ expr = make_ssa_name (TREE_TYPE (expr), tem);
+ }
+ else
+ expr = create_tmp_reg (TREE_TYPE (expr), NULL);
+ gimple_assign_set_lhs (tem, expr);
+ gsi_insert_before (&gsi, tem, GSI_SAME_STMT);
+ }
}
else
{
expr = fold_build2_loc (loc, MEM_REF, adj->type, base, off);
expr = build_fold_addr_expr (expr);
+ expr = force_gimple_operand_gsi (&gsi, expr,
+ true, NULL, true, GSI_SAME_STMT);
}
vargs.quick_push (expr);
}
if (adj->op != IPA_PARM_OP_COPY && MAY_HAVE_DEBUG_STMTS)
*************** ipa_modify_call_arguments (struct cgraph
*** 3850,3855 ****
--- 3866,3880 ----
gimple_set_location (new_stmt, gimple_location (stmt));
gimple_call_set_chain (new_stmt, gimple_call_chain (stmt));
gimple_call_copy_flags (new_stmt, stmt);
+ if (gimple_in_ssa_p (cfun))
+ {
+ gimple_set_vuse (new_stmt, gimple_vuse (stmt));
+ if (gimple_vdef (stmt))
+ {
+ gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+ SSA_NAME_DEF_STMT (gimple_vdef (new_stmt)) = new_stmt;
+ }
+ }
if (dump_file && (dump_flags & TDF_DETAILS))
{
*************** ipa_modify_call_arguments (struct cgraph
*** 3867,3875 ****
}
while ((gsi_end_p (prev_gsi) && !gsi_end_p (gsi))
|| (!gsi_end_p (prev_gsi) && gsi_stmt (gsi) == gsi_stmt (prev_gsi)));
-
- update_ssa (TODO_update_ssa);
- free_dominance_info (CDI_DOMINATORS);
}
/* If the expression *EXPR should be replaced by a reduction of a parameter, do
--- 3892,3897 ----