31 setHasBoundedRewriteRecursion();
33 LogicalResult matchAndRewrite(gpu::ShuffleOp op,
35 auto loc = op.getLoc();
36 auto value = op.getValue();
37 auto valueType = value.getType();
38 auto valueLoc = value.getLoc();
43 if (valueType.getIntOrFloatBitWidth() == 32)
49 if (isa<FloatType>(valueType))
50 value = rewriter.
create<arith::BitcastOp>(valueLoc, i64, value);
53 lo = rewriter.
create<arith::TruncIOp>(valueLoc, i32, value);
56 auto c32 = rewriter.
create<arith::ConstantOp>(
58 hi = rewriter.
create<arith::ShRUIOp>(valueLoc, value, c32);
59 hi = rewriter.
create<arith::TruncIOp>(valueLoc, i32, hi);
64 .
create<gpu::ShuffleOp>(op.getLoc(), lo, op.getOffset(),
65 op.getWidth(), op.getMode())
69 .
create<gpu::ShuffleOp>(op.getLoc(), hi, op.getOffset(),
70 op.getWidth(), op.getMode())
74 lo = rewriter.
create<arith::ExtUIOp>(valueLoc, i64, loRes[0]);
77 hi = rewriter.
create<arith::ExtUIOp>(valueLoc, i64, hiRes[0]);
78 hi = rewriter.
create<arith::ShLIOp>(valueLoc, hi, c32);
81 value = rewriter.
create<arith::OrIOp>(loc, hi, lo);
84 if (isa<FloatType>(valueType))
85 value = rewriter.
create<arith::BitcastOp>(valueLoc, valueType, value);
88 auto validity = rewriter.
create<arith::AndIOp>(loc, loRes[1], hiRes[1]);
91 rewriter.
replaceOp(op, {value, validity});
IntegerAttr getIntegerAttr(Type type, int64_t value)
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
This class provides an abstraction over the different types of ranges over Values.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.
void populateGpuShufflePatterns(RewritePatternSet &patterns)
Collect a set of patterns to rewrite shuffle ops within the GPU dialect.
const FrozenRewritePatternSet & patterns
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...