[llvm] Add AMDGPU metadata to copyMetadataForLoad() (PR #110720)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 11:33:34 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Krzysztof Drewniak (krzysz00)
<details>
<summary>Changes</summary>
There's some AMDGPU-specific metadata that should also be propagated when copyMetadataForLoad() is used instead of a copyMetadata().
The amdgpu.last.use metadata is a form of nontemporal hint that should be preserved.
amdgpu.no.remote.memory and amdgpu.no.fine.grained.memory currently only enable certain atomic instructions that aren't always safe on some targets, but they might need to be applied to atomic loads in the future.
---
Full diff: https://github.com/llvm/llvm-project/pull/110720.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/Local.cpp (+10)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index cfe40f91f9a5df..972524c10a71d5 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3445,6 +3445,8 @@ void llvm::copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source) {
MDBuilder MDB(Dest.getContext());
Type *NewType = Dest.getType();
const DataLayout &DL = Source.getDataLayout();
+ LLVMContext &Ctx = Dest.getContext();
+
for (const auto &MDPair : MD) {
unsigned ID = MDPair.first;
MDNode *N = MDPair.second;
@@ -3488,6 +3490,14 @@ void llvm::copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source) {
copyRangeMetadata(DL, Source, N, Dest);
break;
}
+ // Extended last-use / nontemporal hint on AMD GPUs
+ if (ID == Ctx.getMDKindID("amdpu.last.use"))
+ Dest.setMetadata(ID, N);
+ // Currently only relevant to atomics
+ else if (ID == Ctx.getMDKindID("amdgpu.no.remote.memory"))
+ Dest.setMetadata(ID, N);
+ else if (ID == Ctx.getMDKindID("amdgpu.no.fine.grained.memory"))
+ Dest.setMetadata(ID, N);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/110720
More information about the llvm-commits
mailing list