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)


Jakub Jelinek 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.

Nice, this will also allow to remove range checks at expand time!

Paolo


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