[llvm] 31b6093 - [Scalar] Teach matchExpandedRem to return std::optional (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 20 22:38:49 PST 2022


Author: Kazu Hirata
Date: 2022-11-20T22:38:43-08:00
New Revision: 31b6093434e25bc6cf20ed9ee479557ebbe938f3

URL: https://github.com/llvm/llvm-project/commit/31b6093434e25bc6cf20ed9ee479557ebbe938f3
DIFF: https://github.com/llvm/llvm-project/commit/31b6093434e25bc6cf20ed9ee479557ebbe938f3.diff

LOG: [Scalar] Teach matchExpandedRem to return std::optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/DivRemPairs.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/DivRemPairs.cpp b/llvm/lib/Transforms/Scalar/DivRemPairs.cpp
index 66c9d9f0902a4..fe7fdcd2b5a2c 100644
--- a/llvm/lib/Transforms/Scalar/DivRemPairs.cpp
+++ b/llvm/lib/Transforms/Scalar/DivRemPairs.cpp
@@ -26,6 +26,7 @@
 #include "llvm/Support/DebugCounter.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BypassSlowDivision.h"
+#include <optional>
 
 using namespace llvm;
 using namespace llvm::PatternMatch;
@@ -49,10 +50,10 @@ struct ExpandedMatch {
 ///   X - ((X ?/ Y) * Y)
 /// which is equivalent to:
 ///   X ?% Y
-static llvm::Optional<ExpandedMatch> matchExpandedRem(Instruction &I) {
+static std::optional<ExpandedMatch> matchExpandedRem(Instruction &I) {
   Value *Dividend, *XroundedDownToMultipleOfY;
   if (!match(&I, m_Sub(m_Value(Dividend), m_Value(XroundedDownToMultipleOfY))))
-    return llvm::None;
+    return std::nullopt;
 
   Value *Divisor;
   Instruction *Div;
@@ -62,7 +63,7 @@ static llvm::Optional<ExpandedMatch> matchExpandedRem(Instruction &I) {
           m_c_Mul(m_CombineAnd(m_IDiv(m_Specific(Dividend), m_Value(Divisor)),
                                m_Instruction(Div)),
                   m_Deferred(Divisor))))
-    return llvm::None;
+    return std::nullopt;
 
   ExpandedMatch M;
   M.Key.SignedOp = Div->getOpcode() == Instruction::SDiv;


        


More information about the llvm-commits mailing list