[PATCH] Improving LowerSwitch behavior for contiguous ranges

Marcello Maggioni hayarms at gmail.com
Tue Jun 10 18:05:23 PDT 2014


Hello Joerg,

by unreachable default you mean something like this?

int foo(int a) {
  switch (a) {
  case 0:
    return 10;
  case 1:
    return 20;
  case 2:
    return 2;
  case 8:
    return 3;
  case 9:
    return 4;
  case 10:
    return 5;
  default:
    abort();
  }
}

If that is the case it seems to behave as expected. Please check the files
attached

Cheers,
Marcello


2014-06-10 18:37 GMT+01:00 Joerg Sonnenberger <joerg at britannica.bec.de>:

> On Tue, Jun 10, 2014 at 01:26:07PM +0100, Marcello Maggioni wrote:
> > switch (a) {
> > case 0:
> >   do0();
> >   break;
> > case 1:
> >   do1();
> >   break;
> > case 2:
> >   do2();
> >   break;
> > default:
> >   break;
> > }
>
> Can you also check what your changes do if default is unreachable?
> I don't know if we currently handle exploit that to ignore holes have
> have a flat tree, e.g. in this case the trinary check for <,==,> 1.
> Actually, depending on the architecture that might be the preferred form
> anyway...
>
> Joerg
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140611/a8c57d03/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_unswitched.ll
Type: application/octet-stream
Size: 2696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140611/a8c57d03/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg_switched.dot
Type: application/msword
Size: 1785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140611/a8c57d03/attachment.dot>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cfg_unswitched.dot
Type: application/msword
Size: 3789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140611/a8c57d03/attachment-0001.dot>


More information about the llvm-commits mailing list