[PATCH] D127443: [InstCombine] add zeroinitializer handling to memchr folders

Martin Sebor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 9 14:29:12 PDT 2022


msebor created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
msebor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Due to a limitation of the `getConstantStringInfo` function the `memchr` and `memrchr` folders are unable to fold calls with `zeroinitialzer` constant arrays.  These are rare as global top-level objects but likely more common as members of other aggregates, the handling of which has been proposed in D125114 <https://reviews.llvm.org/D125114>.  In anticipation of that enhancement this patch removes the `getConstantStringInfo` limitation and enables two of its clients, the `memchr` and `memrchr` handlers, to fold calls with `zeroinitialzer` constants.  It adds a `TODO` comment to enhance the third client (`memccpy`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127443

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/test/Transforms/InstCombine/memchr-6.ll
  llvm/test/Transforms/InstCombine/memchr-7.ll
  llvm/test/Transforms/InstCombine/memrchr-6.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127443.435682.patch
Type: text/x-patch
Size: 22627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220609/3b344848/attachment.bin>


More information about the llvm-commits mailing list