[PATCH] D128897: [SimplifyCFG] Improve SwitchToLookupTable optimization

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 01:45:12 PDT 2022


hans added a comment.

Thanks for the patch!

I'm concerned that just tweaking the TableIndex and Offset like this might not work in all cases. For example, would your patch work for the case below? (I didn't try it yet)

  bool g(int x);
  
  bool f(int x) {
      switch (x) {
      case 3: return true;
      case 4: return false;
      case 5: return true;
      case 6: return true;
      case 7: return false;
      }
      return g(x);
  }

I'm thinking that instead of tweaking the indexing, maybe a safer way which would play well with the existing logic would be to try to grow the table by inserting default values (when available)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128897/new/

https://reviews.llvm.org/D128897



More information about the llvm-commits mailing list