This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Expand memory intrinsics in PreISelIntrinsicLowering
ClosedPublic

Authored by arsenm on Jun 7 2023, 9:49 AM.

Details

Summary

Expand large or unknown size memory intrinsics into loops in the
default lowering pipeline if the target doesn't have the corresponding
libfunc. Previously AMDGPU had a custom pass which existed to call the
expansion utilities.

With a default no-libcall option, we can remove the libfunc checks in
LoopIdiomRecognize for these, which never made any sense. This also
provides a path to lifting the immarg restriction on
llvm.memcpy.inline.

There seems to be a bug where TLI reports functions as available if
you use -march and not -mtriple.

Diff Detail

Event Timeline

arsenm created this revision.Jun 7 2023, 9:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 9:49 AM
arsenm requested review of this revision.Jun 7 2023, 9:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2023, 9:49 AM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm updated this revision to Diff 529397.Jun 7 2023, 12:04 PM

Delete old pass

aemerson added inline comments.Jun 7 2023, 2:38 PM
llvm/include/llvm/Analysis/TargetTransformInfo.h
359

this doesn't match the name of the function?

361

These don't need to be signed, use unsigned or size_t?

llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
180–183

Again, size can't be signed.

arsenm updated this revision to Diff 529574.Jun 8 2023, 6:14 AM

Make unsigned, move special case interpretation of flag be 0 instead of -1

aemerson accepted this revision.Jun 8 2023, 2:19 PM

LGTM.

This revision is now accepted and ready to land.Jun 8 2023, 2:19 PM
hiraditya added inline comments.Aug 9 2023, 4:12 PM
llvm/docs/ReleaseNotes.rst
274

what happens when someone compiles a libc?
will all the calls to memcpy in libc files convert into for loops?

arsenm added inline comments.Aug 9 2023, 5:30 PM
llvm/docs/ReleaseNotes.rst
274

Ideally the implementation of libc's memcpy would be a call to llvm.memcpy. Runtime libcalls needs to know that it cannot emit such a call during lowering

hiraditya added inline comments.Aug 10 2023, 10:47 AM
llvm/docs/ReleaseNotes.rst
274

Thanks. it'll be great if we had some documentation on this.

arsenm added inline comments.Aug 10 2023, 3:07 PM
llvm/docs/ReleaseNotes.rst
274

Well we don't really, and the current situation is a bit of a mess. RuntimeLibcalls seems to be the forgotten partner to TargetLibraryInfo.

llvm/lib/Target/AMDGPU/AMDGPU.h