This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PING][3.4] Fix PR24470 (middle-end)


Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

> Richard Guenther <rguenther@suse.de> writes:
> 
> | Ping:
> | http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01300.html
> | 
> | Bootstrapping and testing succeeded, as forseen.
> 
> Have a  middle-end maintainer double-check it.

Looks safe enough to me.

Or you could do something like this which may give better code but is
a rather more invasive fix.  This approximates code in mainline.

Ian

Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 106336)
+++ tree-inline.c	(working copy)
@@ -1612,6 +1612,24 @@ expand_calls_inline (tree *tp, inline_da
   walk_tree (tp, expand_call_inline, id, id->tree_pruner);
 }
 
+/* Fold condition of each COND_EXPR.  */
+
+static tree
+fold_cond_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+		void *data ATTRIBUTE_UNUSED)
+{
+  if (TREE_CODE (*tp) == COND_EXPR)
+    {
+      tree cond = fold (TREE_OPERAND (*tp, 0));
+      if (integer_zerop (cond))
+	TREE_OPERAND (*tp, 0) = boolean_false_node;
+      else if (integer_onep (cond))
+	TREE_OPERAND (*tp, 0) = boolean_true_node;
+    }
+
+  return NULL;
+}
+
 /* Expand calls to inline functions in the body of FN.  */
 
 void
@@ -1669,6 +1687,8 @@ optimize_inline_calls (tree fn)
 		VARRAY_ACTIVE_SIZE (id.inlined_fns) * sizeof (tree));
       DECL_INLINED_FNS (fn) = ifn;
     }
+
+  walk_tree_without_duplicates (&DECL_SAVED_TREE (fn), fold_cond_expr, NULL);
 }
 
 /* FN is a function that has a complete body, and CLONE is a function


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]