Patchwork [2/4] Outline fold_or_predicates from add_to_predicate_list.

login
register
mail settings
Submitter Sebastian Pop
Date July 9, 2010, 5:03 p.m.
Message ID <AANLkTimU4XXbpLJbUKcE-zUm-bOuVOoJF04YIq-WcGaU@mail.gmail.com>
Download mbox | patch
Permalink /patch/58414/
State New
Headers show

Comments

Sebastian Pop - July 9, 2010, 5:03 p.m.
On Fri, Jul 9, 2010 at 11:42, Sebastian Pop <sebpop@gmail.com> wrote:
> On Fri, Jul 9, 2010 at 07:12, Richard Guenther <rguenther@suse.de> wrote:
>> On Thu, 8 Jul 2010, Sebastian Pop wrote:
>>
>>>       * tree-if-conv.c (fold_or_predicates): New.
>>>       (add_to_predicate_list): Call it.
>>

Please see attached the updated patch.
The changes with respect to the previous patch are:
Richard Guenther - July 9, 2010, 6:25 p.m.
On Fri, Jul 9, 2010 at 7:03 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> On Fri, Jul 9, 2010 at 11:42, Sebastian Pop <sebpop@gmail.com> wrote:
>> On Fri, Jul 9, 2010 at 07:12, Richard Guenther <rguenther@suse.de> wrote:
>>> On Thu, 8 Jul 2010, Sebastian Pop wrote:
>>>
>>>>       * tree-if-conv.c (fold_or_predicates): New.
>>>>       (add_to_predicate_list): Call it.
>>>
>
> Please see attached the updated patch.
> The changes with respect to the previous patch are:

Ok.

Thanks,
Richard.

> diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
> index b0ac9b2..0f1caaa 100644
> --- a/gcc/tree-if-conv.c
> +++ b/gcc/tree-if-conv.c
> @@ -300,10 +300,10 @@ parse_predicate (tree cond, tree *op0, tree *op1)
>   return ERROR_MARK;
>  }
>
> -/* Returns the fold of predicate C1 OR C2.  */
> +/* Returns the fold of predicate C1 OR C2 at location LOC.  */
>
>  static tree
> -fold_or_predicates (tree c1, tree c2)
> +fold_or_predicates (location_t loc, tree c1, tree c2)
>  {
>   tree op1a, op1b, op2a, op2b;
>   enum tree_code code1 = parse_predicate (c1, &op1a, &op1b);
> @@ -317,8 +317,7 @@ fold_or_predicates (tree c1, tree c2)
>        return t;
>     }
>
> -  return fold_build2_loc (UNKNOWN_LOCATION, TRUTH_OR_EXPR,
> -                         boolean_type_node, c1, c2);
> +  return fold_build2_loc (loc, TRUTH_OR_EXPR, boolean_type_node, c1, c2);
>  }
>
>  /* Add condition NC to the predicate list of basic block BB.  */
> @@ -334,7 +333,10 @@ add_to_predicate_list (basic_block bb, tree nc)
>   if (!is_predicated (bb))
>     bc = nc;
>   else
> -    bc = fold_or_predicates (nc, bb_predicate (bb));
> +    {
> +      bc = bb_predicate (bb);
> +      bc = fold_or_predicates (EXPR_LOCATION (bc), nc, bc);
> +    }
>
>   if (!is_gimple_condexpr (bc))
>     {
>
Sebastian Pop - July 9, 2010, 6:59 p.m.
On Fri, Jul 9, 2010 at 13:25, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Jul 9, 2010 at 7:03 PM, Sebastian Pop <sebpop@gmail.com> wrote:
>> On Fri, Jul 9, 2010 at 11:42, Sebastian Pop <sebpop@gmail.com> wrote:
>>> On Fri, Jul 9, 2010 at 07:12, Richard Guenther <rguenther@suse.de> wrote:
>>>> On Thu, 8 Jul 2010, Sebastian Pop wrote:
>>>>
>>>>>       * tree-if-conv.c (fold_or_predicates): New.
>>>>>       (add_to_predicate_list): Call it.
>>>>
>>
>> Please see attached the updated patch.
>> The changes with respect to the previous patch are:
>
> Ok.
>

Committed r162007.

Patch

From bf4fc497c5d8c7b02b1b03640db6ddff65a227d0 Mon Sep 17 00:00:00 2001
From: Sebastian Pop <sebpop@gmail.com>
Date: Thu, 8 Jul 2010 13:15:14 -0500
Subject: [PATCH] Outline fold_or_predicates from add_to_predicate_list.

	* tree-if-conv.c (fold_or_predicates): New.
	(add_to_predicate_list): Call it.
---
 gcc/tree-if-conv.c |   39 +++++++++++++++++++++------------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 7058ee4..0f1caaa 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -300,6 +300,26 @@  parse_predicate (tree cond, tree *op0, tree *op1)
   return ERROR_MARK;
 }
 
+/* Returns the fold of predicate C1 OR C2 at location LOC.  */
+
+static tree
+fold_or_predicates (location_t loc, 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 (loc, TRUTH_OR_EXPR, boolean_type_node, c1, c2);
+}
+
 /* Add condition NC to the predicate list of basic block BB.  */
 
 static inline void
@@ -314,25 +334,8 @@  add_to_predicate_list (basic_block bb, tree nc)
     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 (EXPR_LOCATION (bc), nc, bc);
     }
 
   if (!is_gimple_condexpr (bc))
-- 
1.7.0.4