[PATCH] D52002: Switch optimization for known maximum switch values

Ayonam Ray via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 18 03:13:14 PDT 2018


ayonam added a comment.

In https://reviews.llvm.org/D52002#1238032, @hans wrote:

> In https://reviews.llvm.org/D52002#1238026, @ayonam wrote:
>
> > In https://reviews.llvm.org/D52002#1237991, @hans wrote:
> >
> > > The default is unreachable here because it would "fall off" the end of the function without returning, which is undefined behaviour. So the switch lowering should be able to remove the range check for the jump table.
> >
> >
> > On second thoughts, I realize that the default may not be unreachable in the case that I mentioned since the block beyond the switch block would then be treated as the default.  Am I right?
>
>
> Yes, if there are statements after the block, that would be treated as the default and it would not be unreachable.


Thanks Hans for the clarification.  I will go ahead and implement your suggestion.  Once done, I will re-post the patch for review.


Repository:
  rL LLVM

https://reviews.llvm.org/D52002





More information about the llvm-commits mailing list