@@ -200,6 +200,11 @@ struct MoveFuncBodyToWarpOp : public OpRewritePattern<gpu::GPUFuncOp> {
200200 using OpRewritePattern<gpu::GPUFuncOp>::OpRewritePattern;
201201 LogicalResult matchAndRewrite (gpu::GPUFuncOp gpuFuncOp,
202202 PatternRewriter &rewriter) const override {
203+ auto uArch = getUArch (xegpu::getChipStr (gpuFuncOp).value_or (" " ));
204+ if (!uArch)
205+ return rewriter.notifyMatchFailure (
206+ gpuFuncOp, " Subgroup distribution requires target attribute attached "
207+ " to set the warp size" );
203208 // If the function only contains a single void return, skip.
204209 if (llvm::all_of (gpuFuncOp.getBody ().getOps (), [](Operation &op) {
205210 return isa<gpu::ReturnOp>(op) && !op.getNumOperands ();
@@ -229,11 +234,6 @@ struct MoveFuncBodyToWarpOp : public OpRewritePattern<gpu::GPUFuncOp> {
229234 rewriter, newGpuFunc.getLoc (), rewriter.getIndexType (),
230235 /* * upperBound = **/ mlir::IntegerAttr ());
231236 ArrayRef<Type> gpuFuncResultType = gpuFuncOp.getFunctionType ().getResults ();
232- auto uArch = getUArch (xegpu::getChipStr (gpuFuncOp).value_or (" " ));
233- if (!uArch)
234- return rewriter.notifyMatchFailure (
235- gpuFuncOp, " Subgroup distribution requires target attribute attached "
236- " to set the warp size" );
237237 auto warpOp = gpu::WarpExecuteOnLane0Op::create (
238238 rewriter, laneId.getLoc (), gpuFuncResultType, laneId,
239239 uArch->getSubgroupSize (), newGpuFunc.getArguments (),
@@ -501,15 +501,14 @@ struct LoadNdDistribution final : public gpu::WarpDistributionPattern {
501501 warpOp, " warp result is not a xegpu::LoadNd op" );
502502
503503 auto loadOp = operand->get ().getDefiningOp <xegpu::LoadNdOp>();
504- // Chip information is required to decide if the layout requires transpose
505- // effect.
506- auto chipStr = xegpu::getChipStr (loadOp);
507- auto uArch = getUArch (chipStr.value_or (" " ));
504+ auto uArch = getUArch (xegpu::getChipStr (loadOp).value_or (" " ));
508505 if (!uArch)
509506 return rewriter.notifyMatchFailure (
510507 loadOp, " xegpu::LoadNdOp require target attribute attached to "
511508 " determine transpose "
512509 " requirement" );
510+ // Chip information is required to decide if the layout requires transpose
511+ // effect.
513512 // Expecting offsets to be present.
514513 SmallVector<OpFoldResult> offsets = loadOp.getMixedOffsets ();
515514 if (offsets.empty ())
0 commit comments