Skip to content

Commit 30d28ca

Browse files
committed
add readlane type check
1 parent 41b2f3f commit 30d28ca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ struct GPUSubgroupSizeOpToROCDL : ConvertOpToLLVMPattern<gpu::SubgroupSizeOp> {
171171
const amdgpu::Chipset chipset;
172172
};
173173

174+
static bool isSupportedReadLaneType(Type type) {
175+
// read(first)lane also supports some vector types, but limit it for scalars
176+
// for now.
177+
return type.isInteger(16) || type.isInteger(32) || type.isInteger(64) ||
178+
isa<Float16Type, BFloat16Type, Float32Type, Float64Type,
179+
LLVM::LLVMPointerType>(type);
180+
}
181+
174182
struct GPUSubgroupBroadcastOpToROCDL
175183
: public ConvertOpToLLVMPattern<gpu::SubgroupBroadcastOp> {
176184
using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
@@ -179,6 +187,9 @@ struct GPUSubgroupBroadcastOpToROCDL
179187
matchAndRewrite(gpu::SubgroupBroadcastOp op, OpAdaptor adaptor,
180188
ConversionPatternRewriter &rewriter) const override {
181189
Value src = adaptor.getSrc();
190+
if (!isSupportedReadLaneType(src.getType()))
191+
return rewriter.notifyMatchFailure(op, "unsupported readlane type");
192+
182193
if (adaptor.getBroadcastType() == gpu::BroadcastType::specific_lane) {
183194
rewriter.replaceOpWithNewOp<ROCDL::ReadlaneOp>(op, src.getType(), src,
184195
adaptor.getLane());

0 commit comments

Comments
 (0)