25 using OpRewritePattern<gpu::SubgroupIdOp>::OpRewritePattern;
27 LogicalResult matchAndRewrite(gpu::SubgroupIdOp op,
28 PatternRewriter &rewriter)
const override {
54 Location loc = op->getLoc();
57 Value dimX = gpu::BlockDimOp::create(rewriter, loc, gpu::Dimension::x);
58 Value dimY = gpu::BlockDimOp::create(rewriter, loc, gpu::Dimension::y);
59 Value tidX = gpu::ThreadIdOp::create(rewriter, loc, gpu::Dimension::x);
60 Value tidY = gpu::ThreadIdOp::create(rewriter, loc, gpu::Dimension::y);
61 Value tidZ = gpu::ThreadIdOp::create(rewriter, loc, gpu::Dimension::z);
64 arith::MulIOp::create(rewriter, loc, indexType, dimY, tidZ);
65 Value dimYxIdZPlusIdY =
66 arith::AddIOp::create(rewriter, loc, indexType, dimYxIdZ, tidY);
67 Value dimYxIdZPlusIdYTimesDimX =
68 arith::MulIOp::create(rewriter, loc, indexType, dimX, dimYxIdZPlusIdY);
69 Value IdXPlusDimYxIdZPlusIdYTimesDimX = arith::AddIOp::create(
70 rewriter, loc, indexType, tidX, dimYxIdZPlusIdYTimesDimX);
71 Value subgroupSize = gpu::SubgroupSizeOp::create(
74 arith::DivUIOp::create(rewriter, loc, indexType,
75 IdXPlusDimYxIdZPlusIdYTimesDimX, subgroupSize);
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
Include the generated interface declarations.
const FrozenRewritePatternSet & patterns
void populateGpuSubgroupIdPatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite SubgroupIdOp op within the GPU dialect.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...