[PATCH] D73000: [InstCombine] Optimize strchr(cststr, C)

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 11:22:16 PST 2020


xbolva00 marked 2 inline comments as done.
xbolva00 added a subscriber: hans.
xbolva00 added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:935
   // It would be really nice to reuse switch lowering here but we can't change
   // the CFG at this point.
   //
----------------
joerg wrote:
> We are planning on doing exactly that, so the above comment needs adjustment?
True.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:948
     // target.
-    // FIXME: On a 64 bit architecture this prevents us from using the
-    // interesting range of alpha ascii chars. We could do better by emitting
-    // two bitfields or shifting the range by 64 if no lower chars are used.
-    if (!DL.fitsInLegalInteger(Max + 1))
-      return nullptr;
+    if (!DL.fitsInLegalInteger(Max + 1)) {
+      // Build chain of OR comparisons
----------------
joerg wrote:
> The switch table logic is fine with lowering it to a multiple tests, isn't it?
Hmm.. building switch directly is for some cases* better choice** than ORs, but I am wondering if this is best solution here -  Maybe @hans could give us some recommendations here?

* https://godbolt.org/z/BuR6St (switch is faster than ors).
** Ideally, we should turn chain of ORs to switch too.

Ideas?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73000





More information about the llvm-commits mailing list