This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][3/2] Remove GENERIC comparison folding from fold_stmt
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 31 Jul 2015 14:24:05 +0200 (CEST)
- Subject: [PATCH][3/2] Remove GENERIC comparison folding from fold_stmt
- Authentication-results: sourceware.org; auth=none
This is the promised 3/2 - it removes simplifying the compare in
COND_EXPRs through fold_binary in fold_gimple_assign.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress
(testing with an assert in place in progress still as well).
Richard.
2015-07-31 Richard Biener <rguenther@suse.de>
* gimple-fold.c (fold_gimple_assign): Remove folding of
the comparison in COND_EXPRs.
Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c (revision 226433)
+++ gcc/gimple-fold.c (working copy)
@@ -416,49 +416,11 @@ fold_gimple_assign (gimple_stmt_iterator
break;
case GIMPLE_TERNARY_RHS:
- /* Try to fold a conditional expression. */
- if (gimple_assign_rhs_code (stmt) == COND_EXPR)
- {
- tree op0 = gimple_assign_rhs1 (stmt);
- tree tem;
- bool set = false;
- location_t cond_loc = gimple_location (stmt);
-
- if (COMPARISON_CLASS_P (op0))
- {
- fold_defer_overflow_warnings ();
- tem = fold_binary_loc (cond_loc,
- TREE_CODE (op0), TREE_TYPE (op0),
- TREE_OPERAND (op0, 0),
- TREE_OPERAND (op0, 1));
- /* This is actually a conditional expression, not a GIMPLE
- conditional statement, however, the valid_gimple_rhs_p
- test still applies. */
- set = (tem && is_gimple_condexpr (tem)
- && valid_gimple_rhs_p (tem));
- fold_undefer_overflow_warnings (set, stmt, 0);
- }
- else if (is_gimple_min_invariant (op0))
- {
- tem = op0;
- set = true;
- }
- else
- return NULL_TREE;
-
- if (set)
- result = fold_build3_loc (cond_loc, COND_EXPR,
- TREE_TYPE (gimple_assign_lhs (stmt)), tem,
- gimple_assign_rhs2 (stmt),
- gimple_assign_rhs3 (stmt));
- }
-
- if (!result)
- result = fold_ternary_loc (loc, subcode,
- TREE_TYPE (gimple_assign_lhs (stmt)),
- gimple_assign_rhs1 (stmt),
- gimple_assign_rhs2 (stmt),
- gimple_assign_rhs3 (stmt));
+ result = fold_ternary_loc (loc, subcode,
+ TREE_TYPE (gimple_assign_lhs (stmt)),
+ gimple_assign_rhs1 (stmt),
+ gimple_assign_rhs2 (stmt),
+ gimple_assign_rhs3 (stmt));
if (result)
{