------- Comment #10 from bonzini at gnu dot org 2008-08-27 19:53 -------
Yet another piece of the puzzle:
Index: tree-ssa-sccvn.c
===================================================================
--- tree-ssa-sccvn.c (revision 139423)
+++ tree-ssa-sccvn.c (working copy)
@@ -2052,6 +2052,40 @@ valueize_expr (tree expr)
return expr;
}
+static tree
+make_expression_gimple (tree t)
+{
+ enum gimple_rhs_class grc = get_gimple_rhs_class (TREE_CODE (t));
+ tree op0 = NULL, op1 = NULL;
+
+ switch (grc)
+ {
+ case GIMPLE_UNARY_RHS:
+ op0 = TREE_OPERAND (t, 0);
+ if (!is_gimple_val (op0))
+ op0 = vn_nary_op_lookup (op0, NULL);
+ if (op0)
+ return build1 (TREE_CODE (t), TREE_TYPE (t), op0);
+ break;
+
+ case GIMPLE_BINARY_RHS:
+ op0 = TREE_OPERAND (t, 0);
+ op1 = TREE_OPERAND (t, 1);
+ if (!is_gimple_val (op0))
+ op0 = vn_nary_op_lookup (op0, NULL);
+ if (!is_gimple_val (op1))
+ op1 = vn_nary_op_lookup (op1, NULL);
+ if (op0 && op1)
+ return build2 (TREE_CODE (t), TREE_TYPE (t), op0, op1);
+ break;
+
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
/* Simplify the binary expression RHS, and return the result if
simplified. */
@@ -2100,10 +2134,14 @@ simplify_binary_expression (gimple stmt)
of operators of operators (IE (a + b) + (a + c))
Otherwise, we will end up with unbounded expressions if
fold does anything at all. */
- if (result && valid_gimple_rhs_p (result))
- return result;
+ if (result)
+ {
+ STRIP_USELESS_TYPE_CONVERSION (result);
+ if (!valid_gimple_rhs_p (result))
+ result = make_expression_gimple (result);
+ }
- return NULL_TREE;
+ return result;
}
/* Simplify the unary expression RHS, and return the result if
@@ -2153,11 +2191,11 @@ simplify_unary_expression (gimple stmt)
if (result)
{
STRIP_USELESS_TYPE_CONVERSION (result);
- if (valid_gimple_rhs_p (result))
- return result;
+ if (!valid_gimple_rhs_p (result))
+ result = make_expression_gimple (result);
}
- return NULL_TREE;
+ return result;
}
/* Try to simplify RHS using equivalences and constant folding. */
However it still does not work because the two "unsigned" types do not match.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37242