From 2789c4f51c5b4693509a3c3220a0abb7ff242922 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 25 Jul 2022 23:00:56 -0700 Subject: [PATCH] [mlir] Use value_or (NFC) --- mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp | 3 +-- mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp index 8ae0c3cdee71..884931770fde 100644 --- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp +++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp @@ -205,8 +205,7 @@ struct AllocaOpLowering : public AllocLikeOpLLVMLowering { auto elementPtrType = this->getElementPtrType(allocaOp.getType()); auto allocatedElementPtr = rewriter.create( - loc, elementPtrType, sizeBytes, - allocaOp.getAlignment() ? *allocaOp.getAlignment() : 0); + loc, elementPtrType, sizeBytes, allocaOp.getAlignment().value_or(0)); return std::make_tuple(allocatedElementPtr, allocatedElementPtr); } diff --git a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp index f980e52c3965..682a0d403c55 100644 --- a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp +++ b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp @@ -426,7 +426,7 @@ struct NVGPUAsyncWaitLowering matchAndRewrite(nvgpu::DeviceAsyncWaitOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const override { // If numGroup is not present pick 0 as a conservative correct value. - int32_t numGroups = adaptor.getNumGroups() ? *adaptor.getNumGroups() : 0; + int32_t numGroups = adaptor.getNumGroups().value_or(0); rewriter.create(op.getLoc(), numGroups); rewriter.eraseOp(op); return success();