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]

Re: [PATCH] Optimize tablejumps for switch statements



On Wed, 24 Oct 2001, Richard Henderson wrote:
> > 	* stmt.c (expand_end_case): Index jumptables from zero for
> > 	suitably small values of minval.
>
> Applied.

Thanks.

> > +               if (! optimize_size
> > +                   && compare_tree_int (minval, 0) > 0
> > +                   && compare_tree_int (minval, 3) < 0
> > +                   && compare_tree_int (maxval, 0) >= 0)
>
> I don't think there's any need to check maxval, since
> we know that maxval >= minval.

This test is only needed to be safe with very large ranges.  The code
below this hunk requires that "range" fits in a HOST_WIDE_INT.  This
was tested for earlier in the routine by handling very large ranges near
the code:

    /* RANGE may be signed and really large ranges will show up as
       negative numbers.  */
    || compare_tree_int (range, 0) < 0

Hence if "minval=1" and "maxval=HOST_WIDE_INT_MAX+1" then the optimization
should not be applied, as the range would fit before the optimization but
not after.  Admittedly, this would be almost impossible to trigger, but
I thought it best to avoid failing if it ever did encounter a 2^32 entry
jump table.

Roger
--


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