[PATCH] D123818: [InstCombine] Fold strnlen calls in equality to zero.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 07:15:04 PDT 2022


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LG -- the current baseline checks are outdated and a bit confusing for that reason, but otherwise this looks right.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:645
+    //   strnlen(x, N) == 0 --> *x == 0
+    return B.CreateZExt(B.CreateLoad(CharTy, Src, "strlenfirst"),
+                        CI->getType());
----------------
msebor wrote:
> xbolva00 wrote:
> > maybe you can drop “strlenfirst” here.. 
> Because the function also handles `strnlen` besides `strlen`?  I can do that but since other loads in the file are annotated I've changed it to `"char0"`.  Let me know if I misunderstood.
Looks like this rename did not happen (though I don't really care either way).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123818



More information about the llvm-commits mailing list