From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18545 invoked by alias); 27 Aug 2008 19:55:19 -0000 Received: (qmail 17064 invoked by uid 48); 27 Aug 2008 19:53:58 -0000 Date: Wed, 27 Aug 2008 19:55:00 -0000 Message-ID: <20080827195358.17063.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug tree-optimization/37242] missed FRE opportunity because of signedness of addition In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "bonzini at gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg02098.txt.bz2 ------- 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