Skip to content

Commit

Permalink
2015-07-14 Richard Biener <[email protected]>
Browse files Browse the repository at this point in the history
	* 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
  • Loading branch information
rguenth committed Jul 14, 2015
1 parent d74b733 commit 8a6be96
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 54 deletions.
8 changes: 8 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2015-07-14 Richard Biener <[email protected]>

* 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.

2015-07-14 Richard Biener <[email protected]>

* genmatch.c (struct operand): Add OP_IF and OP_WITH op_types.
Expand Down
90 changes: 36 additions & 54 deletions gcc/tree-ssa-dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand All @@ -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. */
Expand Down

0 comments on commit 8a6be96

Please sign in to comment.