Skip to content

Commit 670eb8c

Browse files
kazutakahirataSterling-Augustine
authored andcommitted
[mlir] Use std::optional::value_or (NFC) (llvm#109893)
1 parent 0c0b52f commit 670eb8c

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

mlir/lib/Conversion/VectorToXeGPU/VectorToXeGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ createNdDescriptor(PatternRewriter &rewriter, Location loc,
106106
std::optional<int64_t> staticVal = getConstantIntValue(offset);
107107
if (!staticVal)
108108
dynOffsets.push_back(offset);
109-
constOffsets.push_back(staticVal ? *staticVal : ShapedType::kDynamic);
109+
constOffsets.push_back(staticVal.value_or(ShapedType::kDynamic));
110110
}
111111

112112
SmallVector<Value> dynShapes;

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ static LogicalResult generateCopy(
20672067
// fastMemRefType is a constant shaped memref.
20682068
auto maySizeInBytes = getIntOrFloatMemRefSizeInBytes(fastMemRefType);
20692069
// We don't account for things of unknown size.
2070-
*sizeInBytes = maySizeInBytes ? *maySizeInBytes : 0;
2070+
*sizeInBytes = maySizeInBytes.value_or(0);
20712071

20722072
LLVM_DEBUG(emitRemarkForBlock(*block)
20732073
<< "Creating fast buffer of type " << fastMemRefType

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,9 +3504,7 @@ DiagnosedSilenceableFailure transform::VectorizeOp::apply(
35043504

35053505
if (failed(linalg::vectorize(rewriter, target, vectorSizes,
35063506
getScalableSizes(),
3507-
getVectorizeNdExtract().has_value()
3508-
? getVectorizeNdExtract().value()
3509-
: false))) {
3507+
getVectorizeNdExtract().value_or(false)))) {
35103508
return mlir::emitSilenceableFailure(target->getLoc())
35113509
<< "Attempted to vectorize, but failed";
35123510
}

mlir/lib/Dialect/PDL/IR/PDL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ LogicalResult PatternOp::verifyRegions() {
387387
void PatternOp::build(OpBuilder &builder, OperationState &state,
388388
std::optional<uint16_t> benefit,
389389
std::optional<StringRef> name) {
390-
build(builder, state, builder.getI16IntegerAttr(benefit ? *benefit : 0),
390+
build(builder, state, builder.getI16IntegerAttr(benefit.value_or(0)),
391391
name ? builder.getStringAttr(*name) : StringAttr());
392392
state.regions[0]->emplaceBlock();
393393
}

mlir/lib/Dialect/Utils/StaticValueUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ getConstantIntValues(ArrayRef<OpFoldResult> ofrs) {
124124
auto cv = getConstantIntValue(ofr);
125125
if (!cv.has_value())
126126
failed = true;
127-
return cv.has_value() ? cv.value() : 0;
127+
return cv.value_or(0);
128128
});
129129
if (failed)
130130
return std::nullopt;

0 commit comments

Comments
 (0)