[Mlir-commits] [mlir] [mlir][xegpu] Add vector layout conflict handling in XeGPU layout propagation pass. (PR #182402)

Artem Kroviakov llvmlistbot at llvm.org
Sun Feb 22 04:38:42 PST 2026


================
@@ -1270,32 +1387,36 @@ LogicalResult ResolveLayoutConflicts::run() {
   return r.wasInterrupted() ? failure() : success();
 }
 
-/// Helper to get the defining CreateNdDescOp of a tensor descriptor value. This
-/// function tries to find the defining CreateNdDescOp recursively accross
-/// control-flow boundaries.
-static xegpu::CreateNdDescOp getDefiningCreateNdDescOp(Value tdescValue) {
-  // Try to get the defining CreateNdDescOp of the tensor descriptor.
-  auto definingOp = tdescValue.getDefiningOp<xegpu::CreateNdDescOp>();
-  if (definingOp)
-    return definingOp;
-  // If tdescValue is an argument, try to get the tied init value from the
-  // parent loop-like op.
-  if (auto arg = dyn_cast<BlockArgument>(tdescValue)) {
-    auto *parentOp = arg.getOwner()->getParentOp();
-    if (auto loop = dyn_cast<LoopLikeOpInterface>(parentOp)) {
-      OpOperand *tiedInit = loop.getTiedLoopInit(arg);
-      if (tiedInit)
-        return getDefiningCreateNdDescOp(tiedInit->get());
-    }
-  }
-  // If not found, return null.
-  return nullptr;
-}
-
 LogicalResult
 ResolveLayoutConflicts::resolveVectorConsumer(OpOperand &operand) {
-  // TODO: Implement vector consumer layout conflict resolution. Requires layout
-  // utilities.
+  Value vectorValue = operand.get();
+  Operation *consumerOp = operand.getOwner();
+  // Get the current layout of the vector value.
+  auto currLayout = xegpu::getDistributeLayoutAttr(vectorValue);
+  if (!currLayout) {
+    consumerOp->emitError("Vector operand has no layout assigned.");
+    return failure();
+  }
+
+  // Get the expected layout at this operand.
+  auto expectedLayout = getExpectedLayoutAt(operand, currLayout);
+  if (!expectedLayout) {
+    consumerOp->emitError("No expected layout found for vector operand.");
----------------
akroviakov wrote:

Can't we do
```suggestion
    return consumerOp->emitError("No expected layout found for vector operand.");
```
?

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


More information about the Mlir-commits mailing list