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: Possible patch for tree-optimization/13000


Richard Henderson <rth@redhat.com> writes:

> On Wed, Jan 19, 2005 at 10:49:32AM -0500, Ian Lance Taylor wrote:
> > 	* tree-inline.c: Include "tree-flow.h".
> > 	(expand_call_inline): If warn_return_type, warn if non-void inline
> > 	function falls through.
> > 	* tree-cfg.c (execute_warn_function_return): Don't warn about
> > 	control reaching end if TREE_NO_WARNING is set.  Set
> > 	TREE_NO_WARNING.
> 
> Yes, this is about as good as we'll be able to do for 4.0.

Unfortunately the bootstrap failed with a false positive (on grokparms
in c-decl.c), so now I'm testing this patch.  This cleans up
complicated COND_EXPR patterns in GIMPLE enough to avoid the false
positive I've seen.

I hope I'm not going down a rathole here, though.

Ian


2005-01-19  Ian Lance Taylor  <ian@airs.com>

	* gimplify.c (shortcut_cond_expr): Don't emit a jump over the else
	branch if we don't need one.


Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.104
diff -p -u -r2.104 gimplify.c
--- gimplify.c	19 Jan 2005 09:27:18 -0000	2.104
+++ gimplify.c	19 Jan 2005 22:07:46 -0000
@@ -1911,7 +1911,7 @@ shortcut_cond_expr (tree expr)
   tree true_label, false_label, end_label, t;
   tree *true_label_p;
   tree *false_label_p;
-  bool emit_end, emit_false;
+  bool emit_end, emit_false, jump_over_else;
   bool then_se = then_ && TREE_SIDE_EFFECTS (then_);
   bool else_se = else_ && TREE_SIDE_EFFECTS (else_);
 
@@ -2013,6 +2013,16 @@ shortcut_cond_expr (tree expr)
   emit_end = (end_label == NULL_TREE);
   emit_false = (false_label == NULL_TREE);
 
+  jump_over_else = true;
+  if (then_)
+    {
+      tree last = expr_last (then_);
+      if (last
+	  && (TREE_CODE (last) == GOTO_EXPR
+	      || TREE_CODE (last) == RETURN_EXPR))
+	jump_over_else = false;
+    }
+
   pred = shortcut_cond_r (pred, true_label_p, false_label_p);
 
   expr = NULL;
@@ -2021,8 +2031,11 @@ shortcut_cond_expr (tree expr)
   append_to_statement_list (then_, &expr);
   if (else_se)
     {
-      t = build_and_jump (&end_label);
-      append_to_statement_list (t, &expr);
+      if (jump_over_else)
+	{
+	  t = build_and_jump (&end_label);
+	  append_to_statement_list (t, &expr);
+	}
       if (emit_false)
 	{
 	  t = build1 (LABEL_EXPR, void_type_node, false_label);


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