This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/37242] missed FRE opportunity because of signedness of addition
- From: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Aug 2008 20:17:36 -0000
- Subject: [Bug tree-optimization/37242] missed FRE opportunity because of signedness of addition
- References: <bug-37242-7849@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #11 from rguenther at suse dot de 2008-08-27 20:17 -------
Subject: Re: missed FRE opportunity because of
signedness of addition
On Wed, 27 Aug 2008, bonzini at gnu dot org wrote:
> 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);
A good idea to lookup this final expression before building it.
> + 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);
Likewise.
> + 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.
What do they look like?
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37242