[llvm] [IR] Simplify comparisons with std::optional (NFC) (PR #105624)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 00:08:34 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

For variable X of type std::optional, X && X.has_value(Y) == Z is
equivalent to X == Z.


---
Full diff: https://github.com/llvm/llvm-project/pull/105624.diff


1 Files Affected:

- (modified) llvm/lib/IR/VectorBuilder.cpp (+1-2) 


``````````diff
diff --git a/llvm/lib/IR/VectorBuilder.cpp b/llvm/lib/IR/VectorBuilder.cpp
index 8dbf25277bf5d2..b8f56a7a2e5f9b 100644
--- a/llvm/lib/IR/VectorBuilder.cpp
+++ b/llvm/lib/IR/VectorBuilder.cpp
@@ -96,8 +96,7 @@ Value *VectorBuilder::createVectorInstructionImpl(Intrinsic::ID VPID,
     // Insert mask and evl operands in between the instruction operands.
     for (size_t VPParamIdx = 0, ParamIdx = 0; VPParamIdx < NumVPParams;
          ++VPParamIdx) {
-      if ((MaskPosOpt && MaskPosOpt.value_or(NumVPParams) == VPParamIdx) ||
-          (VLenPosOpt && VLenPosOpt.value_or(NumVPParams) == VPParamIdx))
+      if (MaskPosOpt == VPParamIdx || VLenPosOpt == VPParamIdx)
         continue;
       assert(ParamIdx < NumInstParams);
       IntrinParams[VPParamIdx] = InstOpArray[ParamIdx++];

``````````

</details>


https://github.com/llvm/llvm-project/pull/105624


More information about the llvm-commits mailing list