================
@@ -866,13 +866,61 @@ def SMRDBufferImm   : ComplexPattern<iPTR, 1, 
"SelectSMRDBufferImm">;
 def SMRDBufferImm32 : ComplexPattern<iPTR, 1, "SelectSMRDBufferImm32">;
 def SMRDBufferSgprImm : ComplexPattern<iPTR, 2, "SelectSMRDBufferSgprImm">;
 
+class SMRDAlignedLoadPat<PatFrag Op> : PatFrag <(ops node:$ptr), (Op 
node:$ptr), [{
+  // Ignore the alignment check if XNACK support is disabled.
+  if (!Subtarget->isXNACKEnabled())
+    return true;
+
+  // Returns true if it is a single dword load or naturally aligned 
multi-dword load.
+  LoadSDNode *Ld = cast<LoadSDNode>(N);
+  unsigned Size = Ld->getMemoryVT().getStoreSize();
+  return Size <= 4 || Ld->getAlign().value() >= Size;
+}]> {
+  let GISelPredicateCode = [{
+  if (!Subtarget->isXNACKEnabled())
+    return true;
+
+  auto &Ld = cast<GLoad>(MI);
+  TypeSize Size = Ld.getMMO().getSize().getValue();
+  return Size <= 4 || Ld.getMMO().getAlign().value() >= Size;
+  }];
+}
+
+class SMRDUnalignedLoadPat<PatFrag Op> : PatFrag <(ops node:$ptr), (Op 
node:$ptr), [{
----------------
jayfoad wrote:

I don't think you need this class at all, since the _ec forms should work in 
all cases. It's just an optimization to prefer the non-_ec forms when the load 
is suitable aligned, and you can handle that with DAG pattern priority (maybe 
by setting AddedComplexity).

https://github.com/llvm/llvm-project/pull/96163
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to