[llvm] 237784d - [AMDGPU] Remove std::optional from VOPD::ComponentProps. NFC.

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 21 11:09:04 PDT 2023


Author: Stanislav Mekhanoshin
Date: 2023-07-21T10:52:37-07:00
New Revision: 237784dd3005e1bb7495fe304d55d98f926c295c

URL: https://github.com/llvm/llvm-project/commit/237784dd3005e1bb7495fe304d55d98f926c295c
DIFF: https://github.com/llvm/llvm-project/commit/237784dd3005e1bb7495fe304d55d98f926c295c.diff

LOG: [AMDGPU] Remove std::optional from VOPD::ComponentProps. NFC.

This class has to be fast and efficient with a trivial copy
constructor.

Differential Revision: https://reviews.llvm.org/D155881

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index d4e34c79c23465..bdf7ccad9c76eb 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -573,7 +573,7 @@ constexpr unsigned COMPONENTS_NUM = 2;
 class ComponentProps {
 private:
   unsigned SrcOperandsNum = 0;
-  std::optional<unsigned> MandatoryLiteralIdx;
+  unsigned MandatoryLiteralIdx = ~0u;
   bool HasSrc2Acc = false;
 
 public:
@@ -589,13 +589,13 @@ class ComponentProps {
   }
 
   // Return true iif this component has a mandatory literal.
-  bool hasMandatoryLiteral() const { return MandatoryLiteralIdx.has_value(); }
+  bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
 
   // If this component has a mandatory literal, return component operand
   // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
   unsigned getMandatoryLiteralCompOperandIndex() const {
     assert(hasMandatoryLiteral());
-    return *MandatoryLiteralIdx;
+    return MandatoryLiteralIdx;
   }
 
   // Return true iif this component has operand
@@ -611,8 +611,7 @@ class ComponentProps {
 private:
   bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
     assert(CompSrcIdx < Component::MAX_SRC_NUM);
-    return hasMandatoryLiteral() &&
-           *MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
+    return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
   }
 };
 


        


More information about the llvm-commits mailing list