[PATCH] D122836: [SimplifyLibCalls] Fold more memchr calls

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 14:28:28 PDT 2022


xbolva00 added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:900
+
+  if (MaxLen == 1) {
+    // Fold memchr(x, y, 1) --> *x == y ? x : null for any x and y,
----------------
LenC->isOne() seems like as a good suggestion.


Then you can use..

Str = Str.substr(0, LenC->getZExtValue());


One less variable to keep in mind when reading.


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

https://reviews.llvm.org/D122836



More information about the llvm-commits mailing list