[Mlir-commits] [mlir] [mlir][spirv] Retain nontemporal attribute when converting memref load/store (PR #82119)

Jakub Kuderski llvmlistbot at llvm.org
Mon Feb 26 07:21:32 PST 2024


================
@@ -445,15 +445,23 @@ DeallocOpPattern::matchAndRewrite(memref::DeallocOp operation,
 // LoadOp
 //===----------------------------------------------------------------------===//
 
-using AlignmentRequirements =
+using MemoryRequirements =
     FailureOr<std::pair<spirv::MemoryAccessAttr, IntegerAttr>>;
 
 /// Given an accessed SPIR-V pointer, calculates its alignment requirements, if
 /// any.
-static AlignmentRequirements calculateRequiredAlignment(Value accessedPtr) {
+static MemoryRequirements calculateMemoryRequirements(Value accessedPtr,
+                                                      bool isNontemporal) {
+  MLIRContext *ctx = accessedPtr.getContext();
   auto ptrType = cast<spirv::PointerType>(accessedPtr.getType());
-  if (ptrType.getStorageClass() != spirv::StorageClass::PhysicalStorageBuffer)
+  if (ptrType.getStorageClass() != spirv::StorageClass::PhysicalStorageBuffer) {
+    if (isNontemporal) {
+      return std::pair{
+          spirv::MemoryAccessAttr::get(ctx, spirv::MemoryAccess::Nontemporal),
+          IntegerAttr{}};
----------------
kuhar wrote:

Why is this  mutually exclusive? We can't have aligned nontermoral accesses?

https://github.com/llvm/llvm-project/pull/82119


More information about the Mlir-commits mailing list