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: Fix the tree part of the mainline breakage


On Friday 28 May 2004 17:01, Diego Novillo wrote:
> On Thu, 2004-05-27 at 15:29, Steven Bosscher wrote:
> > 	* gimplify.c (sort_case_labels): New.  Split out from...
> > 	(gimplify_switch_expr): ...here.  Use it.
> > 	* tree-eh.c (lower_try_finally_switch): Sort the labels of
> > 	the SWITCH_EXPR created here before leaving the function.
> > 	* tree.c (sort_case_labels): Add prototype.
>
> Looks fine.  But...
>
> > +   size_t len = TREE_VEC_LENGTH (label_vec);
> > +   tree default_case = TREE_VEC_ELT (label_vec, len - 1);
> > +
> > +   if (CASE_LOW (default_case))
> > +     {
> > +       size_t i;
> > +
> > +       /* The last label in the vector should be the default case
> > +          but it is not.  */
> > +       for (i = 0; i < len; ++i)
> > + 	{
> > + 	  tree t = TREE_VEC_ELT (label_vec, i);
> > + 	  if (!CASE_LOW (t))
> > + 	    {
> > + 	      default_case = t;
> > + 	      TREE_VEC_ELT (label_vec, i) = TREE_VEC_ELT (label_vec, len - 1);
> > + 	      TREE_VEC_ELT (label_vec, len - 1) = default_case;
> > + 	      break;
> > + 	    }
> > + 	}
> > +     }
> > +
>
> Why didn't you remove this chunk out of gimplify_switch_expr?  It seems
> that we are now doing this check twice.

In gimplify.c we don't know yet if there is a default case.  We
look for one and _may_ find one.  But that's not guaranteed, so
we have to look at all labels and see if there is one, and when
there is no default case, we build one.  One could remove those
two lines to move it into the last position of the label vector
and things would still work.  But the idea was, when you have 
just looked it up, why not move it to the end right there, so
you don't have to search the default case _again_ when you're in
sort_case_labels.

Gr.
Steven





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