[PATCH] D104801: [MemCpyOpt] Enable memcpy optimization for NVPTX back-end.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 24 02:31:09 PDT 2021


fhahn added a comment.

In D104801#2836940 <https://reviews.llvm.org/D104801#2836940>, @tra wrote:

> In D104801#2836912 <https://reviews.llvm.org/D104801#2836912>, @nikic wrote:
>
>> I think these questions are rather related. Why does NVPTX require special handling here? If these libcalls are actually available, then you need to enable them in TLI. If they aren't, but the intrinsics form is still usable, then the libcall checks in MemCpyOpt are wrong and we should adjust those. A separate TTI hook seems like the wrong solution in either case.
>
> NVPTX is... special.
> There's no standard library of any kind on the GPU, hence no libcalls.
> We do make an effort to provide enough functionality to keep things working. 
> E.g. most of the math functions end up being pulled from an external bitcode library. 
> We rely on memcpy/memset intrinsics to get replaced by loops by one of NVPTX-specific passes.
>
> So, reporting libcalls as unavailable is correct.
> "memcpy/memset intrinsics are still usable" is... mostly true. It is for the early passes. We do have some corner cases where we en up materializing them too late, but it's rarely an issue in practice.
> Given that this behavior is very specific to this particular back-end and that the NVPTX back-end does something rather peculiar,  TTI is an appropriate source for the hint, IMO. 
> I don't think we have a good way to express "things work in a weird way here" in a back-end agnostic way here.

So IIUC the behavior you want to express is that certain lib functions actually are considered available up to a point? I'm not sure about having a dedicated TTI hook to specifically enable/disable the pass. Would it be possible to mark the lib functions as available until the pass that lowers them runs (there's `TLI->disableAllFunctions`)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104801



More information about the llvm-commits mailing list