Skip to content

Commit ba0be89

Browse files
authored
[mlir] Simplify Default cases in type switches. NFC. (#165767)
Use default values instead of lambdas when possible. `std::nullopt` and `nullptr` can be used now because of #165724.
1 parent 3d42b48 commit ba0be89

File tree

21 files changed

+26
-26
lines changed

21 files changed

+26
-26
lines changed

mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ static std::optional<uint32_t> mfmaTypeSelectCode(Type mlirElemType) {
935935
.Case([](Float6E2M3FNType) { return 2u; })
936936
.Case([](Float6E3M2FNType) { return 3u; })
937937
.Case([](Float4E2M1FNType) { return 4u; })
938-
.Default([](Type) { return std::nullopt; });
938+
.Default(std::nullopt);
939939
}
940940

941941
/// If there is a scaled MFMA instruction for the input element types `aType`

mlir/lib/Conversion/ArithToAMDGPU/ArithToAMDGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static Value getOriginalVectorValue(Value value) {
432432
current = op.getSource();
433433
return false;
434434
})
435-
.Default([](Operation *) { return false; });
435+
.Default(false);
436436

437437
if (!skipOp) {
438438
break;

mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ struct GPUShuffleConversion final : ConvertOpToLLVMPattern<gpu::ShuffleOp> {
259259
}
260260
return std::nullopt;
261261
})
262-
.Default([](auto) { return std::nullopt; });
262+
.Default(std::nullopt);
263263
}
264264

265265
static std::optional<std::string> getFuncName(gpu::ShuffleMode mode,

mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static bool isZeroConstant(Value val) {
4646
[](auto floatAttr) { return floatAttr.getValue().isZero(); })
4747
.Case<IntegerAttr>(
4848
[](auto intAttr) { return intAttr.getValue().isZero(); })
49-
.Default([](auto) { return false; });
49+
.Default(false);
5050
}
5151

5252
static LogicalResult storeLoadPreconditions(PatternRewriter &rewriter,

mlir/lib/Dialect/Arith/IR/ArithOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,7 @@ std::optional<TypedAttr> mlir::arith::getNeutralElement(Operation *op) {
27512751
.Case([](arith::MaxSIOp op) { return AtomicRMWKind::maxs; })
27522752
.Case([](arith::MinSIOp op) { return AtomicRMWKind::mins; })
27532753
.Case([](arith::MulIOp op) { return AtomicRMWKind::muli; })
2754-
.Default([](Operation *op) { return std::nullopt; });
2754+
.Default(std::nullopt);
27552755
if (!maybeKind) {
27562756
return std::nullopt;
27572757
}

mlir/lib/Dialect/GPU/Transforms/EliminateBarriers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static Value getBase(Value v) {
330330
v = op.getSrc();
331331
return true;
332332
})
333-
.Default([](Operation *) { return false; });
333+
.Default(false);
334334
if (!shouldContinue)
335335
break;
336336
}
@@ -354,7 +354,7 @@ static Value propagatesCapture(Operation *op) {
354354
.Case([](memref::TransposeOp transpose) { return transpose.getIn(); })
355355
.Case<memref::ExpandShapeOp, memref::CollapseShapeOp>(
356356
[](auto op) { return op.getSrc(); })
357-
.Default([](Operation *) { return Value(); });
357+
.Default(nullptr);
358358
}
359359

360360
/// Returns `true` if the given operation is known to capture the given value,
@@ -371,7 +371,7 @@ static std::optional<bool> getKnownCapturingStatus(Operation *op, Value v) {
371371
// These operations are known not to capture.
372372
.Case([](memref::DeallocOp) { return false; })
373373
// By default, we don't know anything.
374-
.Default([](Operation *) { return std::nullopt; });
374+
.Default(std::nullopt);
375375
}
376376

377377
/// Returns `true` if the value may be captured by any of its users, i.e., if

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ static void destructureIndices(Type currType, ArrayRef<GEPArg> indices,
698698
return structType.getBody()[memberIndex];
699699
return nullptr;
700700
})
701-
.Default(Type(nullptr));
701+
.Default(nullptr);
702702
}
703703
}
704704

mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ memsetCanUsesBeRemoved(MemsetIntr op, const MemorySlot &slot,
11111111
.Case<IntegerType, FloatType>([](auto type) {
11121112
return type.getWidth() % 8 == 0 && type.getWidth() > 0;
11131113
})
1114-
.Default([](Type) { return false; });
1114+
.Default(false);
11151115
if (!canConvertType)
11161116
return false;
11171117

mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static bool isCompatibleImpl(Type type, DenseSet<Type> &compatibleTypes) {
798798
// clang-format on
799799
.Case<PtrLikeTypeInterface>(
800800
[](Type type) { return isCompatiblePtrType(type); })
801-
.Default([](Type) { return false; });
801+
.Default(false);
802802

803803
if (!result)
804804
compatibleTypes.erase(type);

mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4499,7 +4499,7 @@ DiagnosedSilenceableFailure transform::DecomposeWinogradOp::applyToOne(
44994499
maybeTransformed = decomposeWinogradOutputTransformOp(rewriter, op);
45004500
return true;
45014501
})
4502-
.Default([&](Operation *op) { return false; });
4502+
.Default(false);
45034503

45044504
if (!supported) {
45054505
DiagnosedSilenceableFailure diag =

0 commit comments

Comments
 (0)