Skip to content

Commit

Permalink
[IR] Simplify comparisons with std::optional (NFC) (llvm#105624)
Browse files Browse the repository at this point in the history
For variable X of type std::optional, X && X.value_or(Y) == Z is
equivalent to X == Z when Y != Z.
  • Loading branch information
kazutakahirata authored and dmpolukhin committed Sep 2, 2024
1 parent e2ebf06 commit a525e8d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/IR/VectorBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++];
Expand Down

0 comments on commit a525e8d

Please sign in to comment.