[PATCH] D129224: [InstCombine] Fold strtoul and strtoull and avoid PR #56293

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 05:07:38 PDT 2022


yurai007 added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:91
+  // Strip leading whitespace.
+  for (unsigned i = 0; i != Str.size(); ++i)
+    if (!isSpace((unsigned char)Str[i])) {
----------------
Couldn't it be simplified a bit to something like: Str = Str.drop_while([](char c) { return isSpace(c); }); ?


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:127
+    // Autodetect Base.
+    if (Str.size() > 1) {
+      if (Str[0] == '0') {
----------------
Couldn't it be simplified a bit to something like:

if (Str.startswith_insensitive("0x")  {
Base = 16;
Str = Str.drop_front(2);
} else {...}

?


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

https://reviews.llvm.org/D129224



More information about the llvm-commits mailing list