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

Yaxun Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 06:08:48 PDT 2023


yaxunl added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:279
+    const auto *ASC = dyn_cast<AddrSpaceCastInst>(I);
+    return ASC && IC.isValidAddrSpaceCast(FromAS, ASC->getDestAddressSpace());
+  }
----------------
Do we really need to check whether the addrspacecast is valid here?

If it is invalid, then it is UB. Therefore we could just assume it is valid.

According to the LLVM IR manual, we can assume the memory pointed to by addrspacecasted pointers are the same, therefore we should be able to do this optimization always.

Another reason is that there should already be validity check for addrspacecast in some target specific passes, therefore there is no need to check it here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147025



More information about the llvm-commits mailing list