summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-14 07:27:04 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-14 07:27:04 +0000
commit8a6be96adfcf9d8372047fecef36f79bde373159 (patch)
treecaf8ef0708871f020b8482d4e5745eeb69c7199c /gcc/tree-ssa-dom.c
parentd74b73356f755a6f806c6ccb78e2ed660cc151b5 (diff)
downloadgcc-8a6be96adfcf9d8372047fecef36f79bde373159.tar.gz
2015-07-14 Richard Biener <rguenther@suse.de>
* tree-ssa-dom.c (record_temporary_equivalences): Merge wideing type conversion case from record_equivalences_from_incoming_edge and use record_equality to record equivalences. (record_equivalences_from_incoming_edge): Call record_temporary_equivalences. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225761 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c90
1 files changed, 36 insertions, 54 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index b5ad2c488f9..77f4ac0f72f 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1420,8 +1420,41 @@ record_temporary_equivalences (edge e)
tree rhs = edge_info->rhs;
/* If we have a simple NAME = VALUE equivalence, record it. */
- if (lhs && TREE_CODE (lhs) == SSA_NAME)
- const_and_copies->record_const_or_copy (lhs, rhs);
+ if (lhs)
+ record_equality (lhs, rhs);
+
+ /* If LHS is an SSA_NAME and RHS is a constant integer and LHS was
+ set via a widening type conversion, then we may be able to record
+ additional equivalences. */
+ if (lhs
+ && TREE_CODE (lhs) == SSA_NAME
+ && is_gimple_constant (rhs)
+ && TREE_CODE (rhs) == INTEGER_CST)
+ {
+ gimple defstmt = SSA_NAME_DEF_STMT (lhs);
+
+ if (defstmt
+ && is_gimple_assign (defstmt)
+ && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (defstmt)))
+ {
+ tree old_rhs = gimple_assign_rhs1 (defstmt);
+
+ /* If the conversion widens the original value and
+ the constant is in the range of the type of OLD_RHS,
+ then convert the constant and record the equivalence.
+
+ Note that int_fits_type_p does not check the precision
+ if the upper and lower bounds are OK. */
+ if (INTEGRAL_TYPE_P (TREE_TYPE (old_rhs))
+ && (TYPE_PRECISION (TREE_TYPE (lhs))
+ > TYPE_PRECISION (TREE_TYPE (old_rhs)))
+ && int_fits_type_p (rhs, TREE_TYPE (old_rhs)))
+ {
+ tree newval = fold_convert (TREE_TYPE (old_rhs), rhs);
+ record_equality (old_rhs, newval);
+ }
+ }
+ }
/* If we have 0 = COND or 1 = COND equivalences, record them
into our expression hash tables. */
@@ -1568,7 +1601,6 @@ record_equivalences_from_incoming_edge (basic_block bb)
{
edge e;
basic_block parent;
- struct edge_info *edge_info;
/* If our parent block ended with a control statement, then we may be
able to record some equivalences based on which outgoing edge from
@@ -1580,57 +1612,7 @@ record_equivalences_from_incoming_edge (basic_block bb)
/* If we had a single incoming edge from our parent block, then enter
any data associated with the edge into our tables. */
if (e && e->src == parent)
- {
- unsigned int i;
-
- edge_info = (struct edge_info *) e->aux;
-
- if (edge_info)
- {
- tree lhs = edge_info->lhs;
- tree rhs = edge_info->rhs;
- cond_equivalence *eq;
-
- if (lhs)
- record_equality (lhs, rhs);
-
- /* If LHS is an SSA_NAME and RHS is a constant integer and LHS was
- set via a widening type conversion, then we may be able to record
- additional equivalences. */
- if (lhs
- && TREE_CODE (lhs) == SSA_NAME
- && is_gimple_constant (rhs)
- && TREE_CODE (rhs) == INTEGER_CST)
- {
- gimple defstmt = SSA_NAME_DEF_STMT (lhs);
-
- if (defstmt
- && is_gimple_assign (defstmt)
- && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (defstmt)))
- {
- tree old_rhs = gimple_assign_rhs1 (defstmt);
-
- /* If the conversion widens the original value and
- the constant is in the range of the type of OLD_RHS,
- then convert the constant and record the equivalence.
-
- Note that int_fits_type_p does not check the precision
- if the upper and lower bounds are OK. */
- if (INTEGRAL_TYPE_P (TREE_TYPE (old_rhs))
- && (TYPE_PRECISION (TREE_TYPE (lhs))
- > TYPE_PRECISION (TREE_TYPE (old_rhs)))
- && int_fits_type_p (rhs, TREE_TYPE (old_rhs)))
- {
- tree newval = fold_convert (TREE_TYPE (old_rhs), rhs);
- record_equality (old_rhs, newval);
- }
- }
- }
-
- for (i = 0; edge_info->cond_equivalences.iterate (i, &eq); ++i)
- record_cond (eq);
- }
- }
+ record_temporary_equivalences (e);
}
/* Dump SSA statistics on FILE. */