aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2013-03-20 22:42:40 -0600
committerJeff Law <law@gcc.gnu.org>2013-03-20 22:42:40 -0600
commit4f1f78b9dce2a046e82012d2f3f44f77351838d2 (patch)
treef4d97c1272264f7310b05780db7d45ee55bfbb42 /gcc/tree-ssa-dom.c
parentefcf217b1c9e82dc377feaeeb6ba86001d0a9d95 (diff)
downloadgcc-4f1f78b9dce2a046e82012d2f3f44f77351838d2.zip
gcc-4f1f78b9dce2a046e82012d2f3f44f77351838d2.tar.gz
gcc-4f1f78b9dce2a046e82012d2f3f44f77351838d2.tar.bz2
tree-ssa-dom.c (record_equivalences_from_incoming_edge): Record addititional equivalences for equality comparisons between an SSA_NAME...
* tree-ssa-dom.c (record_equivalences_from_incoming_edge): Record addititional equivalences for equality comparisons between an SSA_NAME and a constant where the SSA_NAME was set from a widening conversion. * g++.dg/tree-ssa/ssa-dom.C: New test. From-SVN: r196855
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index e8b1551..57b814c 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1135,6 +1135,33 @@ record_equivalences_from_incoming_edge (basic_block bb)
if (lhs)
record_equality (lhs, rhs);
+ /* If LHS is an SSA_NAME and RHS is a constant 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))
+ {
+ 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);
+ tree newval = fold_convert (TREE_TYPE (old_rhs), rhs);
+
+ /* If this was a widening conversion and if RHS is converted
+ to the type of OLD_RHS and has the same value, then we
+ can record an equivalence between OLD_RHS and the
+ converted representation of RHS. */
+ if ((TYPE_PRECISION (TREE_TYPE (lhs))
+ > TYPE_PRECISION (TREE_TYPE (old_rhs)))
+ && operand_equal_p (rhs, newval, 0))
+ record_equality (old_rhs, newval);
+ }
+ }
+
for (i = 0; edge_info->cond_equivalences.iterate (i, &eq); ++i)
record_cond (eq);
}