aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-10-26 14:59:36 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-10-26 14:59:36 +0000
commitfec40d06dadf9cd5bf4adb0ee9a47f267e6c7693 (patch)
treed47ed2f8bb25f49bb46b11ff5fbf031bfdb518f8
parent0b7c37ee712fdc5164db6cd6acb816fcf6752c02 (diff)
downloadgcc-fec40d06dadf9cd5bf4adb0ee9a47f267e6c7693.zip
gcc-fec40d06dadf9cd5bf4adb0ee9a47f267e6c7693.tar.gz
gcc-fec40d06dadf9cd5bf4adb0ee9a47f267e6c7693.tar.bz2
Allow more complex call replacements in gimple-fold.c
An upcoming patch adds a match.pd rule that folds pow(pow(x,y),z) to pow(x,y*z). This fold can reuse the existing pow gimple statement and simply replace the operands with x and y*z. However, the y*z itself requires a separate gimple statement and the code wasn't prepared to handle that. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * gimple-fold.c (replace_stmt_with_simplification): Don't allow new statements to be inserted if inplace. Allow calls to have nonempty sequences. From-SVN: r229371
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimple-fold.c14
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f7371b0..b35b201 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-26 Richard Sandiford <richard.sandiford@arm.com>
+
+ * gimple-fold.c (replace_stmt_with_simplification): Don't allow
+ new statements to be inserted if inplace. Allow calls to have
+ nonempty sequences.
+
2015-10-26 Richard Biener <rguenther@suse.de>
* tree-object-size.c: Remove builtins.h include, include tree-cfg.h.
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 1869c09..392738d 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -3289,6 +3289,11 @@ replace_stmt_with_simplification (gimple_stmt_iterator *gsi,
&& !has_use_on_stmt (ops[2], stmt)))
return false;
+ /* Don't insert new statements when INPLACE is true, even if we could
+ reuse STMT for the final statement. */
+ if (inplace && !gimple_seq_empty_p (*seq))
+ return false;
+
if (gcond *cond_stmt = dyn_cast <gcond *> (stmt))
{
gcc_assert (rcode.is_tree_code ());
@@ -3365,7 +3370,14 @@ replace_stmt_with_simplification (gimple_stmt_iterator *gsi,
}
if (i < 3)
gcc_assert (ops[i] == NULL_TREE);
- gcc_assert (gimple_seq_empty_p (*seq));
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "gimple_simplified to ");
+ if (!gimple_seq_empty_p (*seq))
+ print_gimple_seq (dump_file, *seq, 0, TDF_SLIM);
+ print_gimple_stmt (dump_file, gsi_stmt (*gsi), 0, TDF_SLIM);
+ }
+ gsi_insert_seq_before (gsi, *seq, GSI_SAME_STMT);
return true;
}
else if (!inplace)