From patchwork Thu Jul 8 21:41:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/4] Outline fold_or_predicates from add_to_predicate_list. Date: Thu, 08 Jul 2010 11:41:23 -0000 From: Sebastian Pop X-Patchwork-Id: 58303 Message-Id: <1278625285-12667-3-git-send-email-sebpop@gmail.com> To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, matz@suse.de, Sebastian Pop * tree-if-conv.c (fold_or_predicates): New. (add_to_predicate_list): Call it. --- gcc/tree-if-conv.c | 43 ++++++++++++++++++++++--------------------- 1 files changed, 22 insertions(+), 21 deletions(-) diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 34b4159..cac5a3b 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -300,6 +300,27 @@ parse_predicate (tree cond, tree *op0, tree *op1) return ERROR_MARK; } +/* Returns the fold of predicate C1 OR C2. */ + +static tree +fold_or_predicates (tree c1, tree c2) +{ + tree op1a, op1b, op2a, op2b; + enum tree_code code1 = parse_predicate (c1, &op1a, &op1b); + enum tree_code code2 = parse_predicate (c2, &op2a, &op2b); + + if (code1 != ERROR_MARK && code2 != ERROR_MARK) + { + tree t = maybe_fold_or_comparisons (code1, op1a, op1b, + code2, op2a, op2b); + if (t) + return t; + } + + return fold_build2_loc (UNKNOWN_LOCATION, TRUTH_OR_EXPR, + boolean_type_node, c1, c2); +} + /* Add condition NC to the predicate list of basic block BB. */ static inline void @@ -313,27 +334,7 @@ add_to_predicate_list (basic_block bb, tree nc) if (!is_predicated (bb)) bc = nc; else - { - enum tree_code code1, code2; - tree op1a, op1b, op2a, op2b; - - bc = bb_predicate (bb); - code1 = parse_predicate (bc, &op1a, &op1b); - code2 = parse_predicate (nc, &op2a, &op2b); - - if (code1 != ERROR_MARK && code2 != ERROR_MARK) - { - tree t = maybe_fold_or_comparisons (code1, op1a, op1b, - code2, op2a, op2b); - if (!t) - t = fold_build2_loc (EXPR_LOCATION (bc), TRUTH_OR_EXPR, - boolean_type_node, bc, nc); - bc = t; - } - else - bc = fold_build2_loc (EXPR_LOCATION (bc), TRUTH_OR_EXPR, - boolean_type_node, bc, nc); - } + bc = fold_or_predicates (nc, bb_predicate (bb)); if (!is_gimple_condexpr (bc)) {