This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Don't add a new label for implicit default label if case labels cover the whole range (PR middle-end/39666)
On Thu, Apr 30, 2009 at 12:06 AM, Jakub Jelinek <firstname.lastname@example.org> wrote:
> On Wed, Apr 29, 2009 at 11:59:52PM +0200, Richard Guenther wrote:
>> On Wed, Apr 29, 2009 at 11:44 PM, Jakub Jelinek <email@example.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
Ok. I wasn't sure if TYPE_MIN/MAX_VALUE covers all valid values
(that fix in the minimal precision) or if it is the minimum/maximum of
the enum elements.
> Ada is something I couldn't test now.
Maybe Eric can confirm if gigi uses base types for switch operands.
> ? ? ? ?Jakub