Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

SimplifyCFG.cpp fails to build lookup tables in many cases #38019

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR39046
Status NEW
Importance P normal
Reported by Shawn Landden (slandden@gmail.com)
Reported on 2018-09-21 23:34:03 -0700
Last modified on 2019-06-07 20:41:47 -0700
Version trunk
Hardware PC Linux
CC hfinkel@anl.gov, llvm-bugs@lists.llvm.org, llvm-dev@ndave.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
https://godbolt.org/z/QuklOn

#include <stdio.h>
int switchexample(unsigned char num) {
   switch(num) {
   case 0:
        return 120;
   case 1:
        return 119;
   case 3:
        return 118;
   case 4:
        return 118;
   case 11:
        return 117;
   case 12:
        return 116;
   case 13:
        return 115;
   case 14:
        return 114;
   case 15:
        return 113;
   case 16:
        return 112;
   case 17:
        return 111;
   case 18:
        return 110;
   case 19:
        return 109;
   case 37: //change this to 36 and it will use a lookup table
        return 108;
   case 35:
        return 108;
   default:
        puts("hi");
        return 1;
   }
}

Noticed while working on 39013
Quuxplusone commented 6 years ago

Perhaps the lookup table simplification belongs in the backend.