aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-outof-ssa.c
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2013-09-26 13:38:54 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2013-09-26 13:38:54 +0000
commit78bca40d1df75b037b946d10dc1151fffc17fbf9 (patch)
treebf1ee8e68198405d46df67850c59d9346411f5b3 /gcc/tree-outof-ssa.c
parentff2a63a749c386637ef085f7bc3102a8d8d2aab3 (diff)
downloadgcc-78bca40d1df75b037b946d10dc1151fffc17fbf9.zip
gcc-78bca40d1df75b037b946d10dc1151fffc17fbf9.tar.gz
gcc-78bca40d1df75b037b946d10dc1151fffc17fbf9.tar.bz2
tree-ssa-live.h (find_replaceable_exprs, [...]): Move prototypes to...
2013-09-26 Andrew MacLeod <amacleod@redhat.com> * tree-ssa-live.h (find_replaceable_exprs, dump_replaceable_exprs): Move prototypes to... * tree-ssa-ter.h: New File. Move prototypes here. * tree-flow.h (stmt_is_replaceable_p): Remove prototype. * tree-outof-ssa.h: New. Rename ssaexpand.h, include tree-ssa-ter.h. * tree-outof-ssa.c (ssa_is_replaceable_p): New. Refactor common bits from is_replaceable_p. * tree-ssa-ter.c (is_replaceable_p, stmt_is_replaceable_p): Delete. (ter_is_replaceable_p): New. Use new refactored ssa_is_replaceable_p. (process_replaceable): Use ter_is_replaceable_p. (find_replaceable_in_bb): Use ter_is_replaceable_p. * expr.c (stmt_is_replaceable_p): Relocate from tree-ssa-ter.c. Use newly refactored ssa_is_replaceable_p. * cfgexpand.c: Include tree-outof-ssa.h. * ssaexpand.h: Delete. From-SVN: r202946
Diffstat (limited to 'gcc/tree-outof-ssa.c')
-rw-r--r--gcc/tree-outof-ssa.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 5ed145d..42c90d4 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -30,12 +30,67 @@ along with GCC; see the file COPYING3. If not see
#include "tree-ssa.h"
#include "dumpfile.h"
#include "diagnostic-core.h"
-#include "ssaexpand.h"
+#include "tree-outof-ssa.h"
/* FIXME: A lot of code here deals with expanding to RTL. All that code
should be in cfgexpand.c. */
#include "expr.h"
+/* Return TRUE if expression STMT is suitable for replacement. */
+
+bool
+ssa_is_replaceable_p (gimple stmt)
+{
+ use_operand_p use_p;
+ tree def;
+ gimple use_stmt;
+
+ /* Only consider modify stmts. */
+ if (!is_gimple_assign (stmt))
+ return false;
+
+ /* If the statement may throw an exception, it cannot be replaced. */
+ if (stmt_could_throw_p (stmt))
+ return false;
+
+ /* Punt if there is more than 1 def. */
+ def = SINGLE_SSA_TREE_OPERAND (stmt, SSA_OP_DEF);
+ if (!def)
+ return false;
+
+ /* Only consider definitions which have a single use. */
+ if (!single_imm_use (def, &use_p, &use_stmt))
+ return false;
+
+ /* Used in this block, but at the TOP of the block, not the end. */
+ if (gimple_code (use_stmt) == GIMPLE_PHI)
+ return false;
+
+ /* There must be no VDEFs. */
+ if (gimple_vdef (stmt))
+ return false;
+
+ /* Float expressions must go through memory if float-store is on. */
+ if (flag_float_store
+ && FLOAT_TYPE_P (gimple_expr_type (stmt)))
+ return false;
+
+ /* An assignment with a register variable on the RHS is not
+ replaceable. */
+ if (gimple_assign_rhs_code (stmt) == VAR_DECL
+ && DECL_HARD_REGISTER (gimple_assign_rhs1 (stmt)))
+ return false;
+
+ /* No function calls can be replaced. */
+ if (is_gimple_call (stmt))
+ return false;
+
+ /* Leave any stmt with volatile operands alone as well. */
+ if (gimple_has_volatile_ops (stmt))
+ return false;
+
+ return true;
+}
/* Used to hold all the components required to do SSA PHI elimination.