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


Eric Botcazou <ebotcazou@libertysurf.fr> writes:

> > Index: gimple-low.c
> > ===================================================================
> > RCS file: /cvs/gcc/gcc/gcc/gimple-low.c,v
> > retrieving revision 2.17
> > diff -p -u -r2.17 gimple-low.c
> > --- gimple-low.c	18 Jan 2005 11:36:14 -0000	2.17
> > +++ gimple-low.c	21 Jan 2005 02:34:56 -0000
> > @@ -278,11 +278,17 @@ block_may_fallthru (tree block)
> >      case GOTO_EXPR:
> >      case RETURN_EXPR:
> >      case RESX_EXPR:
> > -    case SWITCH_EXPR:
> >        /* Easy cases.  If the last statement of the block implies
> >  	 control transfer, then we can't fall through.  */
> >        return false;
> >
> > +    case SWITCH_EXPR:
> > +      /* If SWITCH_LABELS is set, this is lowered, and represents a
> > +	 branch to a selected label and hence can not fall through.
> > +	 Otherwise SWITCH_BODY is set, and the switch can fall
> > +	 through.  */
> > +      return SWITCH_LABELS (stmt) != NULL_TREE;
> > +
> >      case COND_EXPR:
> >        if (block_may_fallthru (COND_EXPR_THEN (stmt)))
> >  	return true;
> 
> Is it me or the code implements the reverse of what the comment says?

The code is wrong.  Whoops.  I couldn't work out how to construct a
test case for this, but it should be fixed anyhow.  I'm committing the
appended patch as obvious.

Ian


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

	* gimple-low.c (block_may_fallthru): Correct handling of
	SWITCH_EXPR--may fall through if SWITCH_LABELS is NULL.


Index: gimple-low.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimple-low.c,v
retrieving revision 2.18
diff -u -r2.18 gimple-low.c
--- gimple-low.c	21 Jan 2005 19:05:22 -0000	2.18
+++ gimple-low.c	26 Jan 2005 03:15:34 -0000
@@ -287,7 +287,7 @@
 	 branch to a selected label and hence can not fall through.
 	 Otherwise SWITCH_BODY is set, and the switch can fall
 	 through.  */
-      return SWITCH_LABELS (stmt) != NULL_TREE;
+      return SWITCH_LABELS (stmt) == NULL_TREE;
 
     case COND_EXPR:
       if (block_may_fallthru (COND_EXPR_THEN (stmt)))


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