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: [PATCH] Don't add a new label for implicit default label if case labels cover the whole range (PR middle-end/39666)


On Wed, Apr 29, 2009 at 11:59:52PM +0200, Richard Guenther wrote:
> On Wed, Apr 29, 2009 at 11:44 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > Hi!
> >
> > If a SWITCH_EXPR doesn't have a default case, but all its case labels
> > together cover all values from type's minimum through maximum, when
> > gimplify_switch_expr adds the default case it can introduce undesirable
> > warnings and pessimize generated code.
> > As the case labels are sorted, it is enough to check that first case label
> > starts at TYPE_MIN_VALUE and last ends at TYPE_MAX_VALUE (to bail out quickly
> > in a typical case) and if so check that adjacent case labels have adjacent
> > ranges.
> >
> > Bootstrapped/regtested on x86_64-linux (except Ada, which is currently
> > broken), will commit when slush is over.
> 
> Hmmm.  Using TYPE_MIN/MAX_VALUE may have issues with both
> enum types in C++ and Ada integer subtypes.

At least for C++ TYPE_MIN/MAX_VALUE is already used by
c_add_case_label/check_case_bounds (throwing out out-of-range case labels,
adjusting other case labels to not start below or end above
TYPE_MIN/MAX_VALUE).
Ada is something I couldn't test now.

	Jakub


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