[PATCH] D147025: [InstCombine] Teach alloca replacement to handle `addrspacecast`

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 21:25:28 PDT 2023


hliao created this revision.
hliao added reviewers: arsenm, yaxunl.
Herald added subscribers: hiraditya, arichardson.
Herald added a project: All.
hliao requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

- As the address space cast may not be valid on a specific target, `addrspacecast` is not handled when an `alloca` is able to be replaced with the source of memcpy/memmove. This patch addresses that by querying a target hook on whether that address space cast is valid. For example, on most GPU targets, the cast from a global pointer to a generic pointer is valid.
- If that cast is allowedd (by querying `isValidAddrSpaceCast`), the replacement is enhanced to handle that `addrspacecast` as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147025

Files:
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Transforms/InstCombine/InstCombiner.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/ptr-replace-alloca.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147025.508886.patch
Type: text/x-patch
Size: 9174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230328/14a76df8/attachment.bin>


More information about the llvm-commits mailing list