[PATCH][match-and-simplify] Change back default behavior of fold_stmt
Richard Biener
rguenther@suse.de
Tue Oct 14 08:45:00 GMT 2014
This changes default behavior of fold_stmt back to _not_ following
SSA use-def chains when trying to simplify things. I had to force
that already for one caller and for the merge to trunk I'd rather
not track down issues in every other existing caller.
This means that fold_stmt will not become more powerful, at least for now.
I still hope to get rid of its use of fold() during the merge process.
Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu.
(yeah, I'm preparing a first batch of changes to merge from the
branch)
Richard.
2014-10-14 Richard Biener <rguenther@suse.de>
* gimple-fold.c (fold_stmt): Make old API never follow SSA edges
when simplifying.
(no_follow_ssa_edges): New function.
* tree-cfg.c (no_follow_ssa_edges): Remove.
(replace_uses_by): Use plain fold_stmt again.
Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c (revision 216146)
+++ gcc/gimple-fold.c (working copy)
@@ -3136,6 +3136,14 @@ fail:
return changed;
}
+/* Valueziation callback that ends up not following SSA edges. */
+
+static tree
+no_follow_ssa_edges (tree)
+{
+ return NULL_TREE;
+}
+
/* Fold the statement pointed to by GSI. In some cases, this function may
replace the whole statement with a new one. Returns true iff folding
makes any changes.
@@ -3146,7 +3154,7 @@ fail:
bool
fold_stmt (gimple_stmt_iterator *gsi)
{
- return fold_stmt_1 (gsi, false, NULL);
+ return fold_stmt_1 (gsi, false, no_follow_ssa_edges);
}
bool
@@ -3167,7 +3175,7 @@ bool
fold_stmt_inplace (gimple_stmt_iterator *gsi)
{
gimple stmt = gsi_stmt (*gsi);
- bool changed = fold_stmt_1 (gsi, true, NULL);
+ bool changed = fold_stmt_1 (gsi, true, no_follow_ssa_edges);
gcc_assert (gsi_stmt (*gsi) == stmt);
return changed;
}
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 216146)
+++ gcc/tree-cfg.c (working copy)
@@ -1709,14 +1709,6 @@ gimple_can_merge_blocks_p (basic_block a
return true;
}
-/* ??? Maybe this should be a generic overload of fold_stmt. */
-
-static tree
-no_follow_ssa_edges (tree)
-{
- return NULL_TREE;
-}
-
/* Replaces all uses of NAME by VAL. */
void
@@ -1773,17 +1765,7 @@ replace_uses_by (tree name, tree val)
recompute_tree_invariant_for_addr_expr (op);
}
- /* If we have sth like
- neighbor_29 = <name> + -1;
- _33 = <name> + neighbor_29;
- and substitute 1 for <name> then when visiting
- _33 first then folding will simplify the stmt
- to _33 = <name>; and the new immediate use will
- be inserted before the stmt iterator marker and
- thus we fail to visit it again, ICEing within the
- has_zero_uses assert.
- Avoid that by never following SSA edges. */
- if (fold_stmt (&gsi, no_follow_ssa_edges))
+ if (fold_stmt (&gsi))
stmt = gsi_stmt (gsi);
if (maybe_clean_or_replace_eh_stmt (orig_stmt, stmt))
More information about the Gcc-patches
mailing list