31struct PromoteShuffleToSwizzlePattern
35 LogicalResult matchAndRewrite(gpu::ShuffleOp op,
36 PatternRewriter &rewriter)
const override {
37 if (op.getMode() != gpu::ShuffleMode::XOR)
39 "only xor shuffle mode is supported");
43 "only 64 width shuffle is supported");
48 "offset must be a constant integer");
50 int64_t offsetValue = *offset;
51 if (offsetValue < 0 || offsetValue >= 32)
53 "offset must be in the range [0, 31]");
55 Location loc = op.getLoc();
56 Value res = amdgpu::SwizzleBitModeOp::create(
57 rewriter, loc, op.getResult(0).getType(), op.getValue(), 31,
67struct PromoteShuffleToPermlanePattern
71 LogicalResult matchAndRewrite(gpu::ShuffleOp op,
72 PatternRewriter &rewriter)
const override {
73 if (op.getMode() != gpu::ShuffleMode::XOR)
75 "only xor shuffle mode is supported");
79 "only 64 width shuffle is supported");
84 "offset must be a constant integer");
86 int64_t offsetValue = *offset;
87 if (offsetValue != 16 && offsetValue != 32)
90 Location loc = op.getLoc();
91 Value res = amdgpu::PermlaneSwapOp::create(
92 rewriter, loc, op.getResult(0).getType(), op.getValue(), offsetValue);
105 if (maybeChipset && *maybeChipset >=
kGfx950)
constexpr Chipset kGfx950
virtual void replaceOp(Operation *op, ValueRange newValues)
Replace the results of the given (original) operation with the specified list of values (replacements...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
static ConstantIntOp create(OpBuilder &builder, Location location, int64_t value, unsigned width)
Include the generated interface declarations.
bool isConstantIntValue(OpFoldResult ofr, int64_t value)
Return true if ofr is constant integer equal to value.
std::optional< int64_t > getConstantIntValue(OpFoldResult ofr)
If ofr is a constant integer or an IntegerAttr, return the integer.
const FrozenRewritePatternSet & patterns
void populateGpuPromoteShuffleToAMDGPUPatterns(RewritePatternSet &patterns, std::optional< amdgpu::Chipset > maybeChipset)
Tries to promote gpu.shuffles to specialized AMDGPU intrinsics.
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...
OpRewritePattern(MLIRContext *context, PatternBenefit benefit=1, ArrayRef< StringRef > generatedNames={})
Patterns must specify the root operation name they match against, and can also specify the benefit of...
Represents the amdgpu gfx chipset version, e.g., gfx90a, gfx942, gfx1103.