[llvm] [LLVM] Clean up code using [not_]equal_to (NFC) (PR #175824)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 13 12:18:44 PST 2026
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/175824
Use llvm::[not_]equal_to landed in d2a521750 ([ADT] Introduce bind_{front,back}, [not_]equal_to, #175056) across LLVM for cleaner code.
>From 80fcd3c07a3198763ed9cce9f14dab5808aebe63 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Tue, 13 Jan 2026 19:13:42 +0000
Subject: [PATCH] [LLVM] Clean up code using [not_]equal_to (NFC)
Use llvm::[not_]equal_to landed in d2a521750 ([ADT] Introduce
bind_{front,back}, [not_]equal_to, #175056) across LLVM for cleaner
code.
---
llvm/lib/Analysis/ConstraintSystem.cpp | 2 +-
llvm/lib/Analysis/InstructionSimplify.cpp | 2 +-
llvm/lib/Analysis/VectorUtils.cpp | 2 +-
llvm/lib/CodeGen/CodeGenPrepare.cpp | 2 +-
llvm/lib/CodeGen/InterleavedAccessPass.cpp | 2 +-
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 +-
.../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 3 +--
llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp | 2 +-
llvm/lib/IR/AsmWriter.cpp | 4 ++--
llvm/lib/IR/ConstantFold.cpp | 4 ++--
llvm/lib/IR/Constants.cpp | 5 ++---
llvm/lib/IR/Instructions.cpp | 2 +-
llvm/lib/IR/ProfDataUtils.cpp | 2 +-
llvm/lib/Support/APFloat.cpp | 3 +--
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp | 2 +-
.../Target/AArch64/AArch64TargetTransformInfo.cpp | 12 ++++++------
.../Target/AMDGPU/AMDGPUTargetTransformInfo.cpp | 2 +-
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp | 4 +---
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp | 4 ++--
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 4 ++--
llvm/lib/Target/NVPTX/NVPTXUtilities.h | 2 +-
llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp | 2 +-
llvm/lib/Target/X86/X86ISelLowering.cpp | 7 +++----
llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 2 +-
.../InstCombine/InstCombineSimplifyDemanded.cpp | 2 +-
llvm/lib/Transforms/Scalar/GVNHoist.cpp | 6 +++---
llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp | 2 +-
llvm/lib/Transforms/Scalar/LoopInterchange.cpp | 2 +-
llvm/lib/Transforms/Scalar/NewGVN.cpp | 2 +-
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 2 +-
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 15 ++++++---------
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 3 +--
llvm/lib/Transforms/Vectorize/VectorCombine.cpp | 9 +++------
33 files changed, 54 insertions(+), 67 deletions(-)
diff --git a/llvm/lib/Analysis/ConstraintSystem.cpp b/llvm/lib/Analysis/ConstraintSystem.cpp
index 6457b6b425c6c..62545586b3554 100644
--- a/llvm/lib/Analysis/ConstraintSystem.cpp
+++ b/llvm/lib/Analysis/ConstraintSystem.cpp
@@ -215,7 +215,7 @@ bool ConstraintSystem::mayHaveSolution() {
bool ConstraintSystem::isConditionImplied(SmallVector<int64_t, 8> R) const {
// If all variable coefficients are 0, we have 'C >= 0'. If the constant is >=
// 0, R is always true, regardless of the system.
- if (all_of(ArrayRef(R).drop_front(1), [](int64_t C) { return C == 0; }))
+ if (all_of(ArrayRef(R).drop_front(1), equal_to(0)))
return R[0] >= 0;
// If there is no solution with the negation of R added to the system, the
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 2b370f7a2fc59..a8823117cdb51 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5610,7 +5610,7 @@ static Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1,
ArrayRef<int> Mask, Type *RetTy,
const SimplifyQuery &Q,
unsigned MaxRecurse) {
- if (all_of(Mask, [](int Elem) { return Elem == PoisonMaskElem; }))
+ if (all_of(Mask, equal_to(PoisonMaskElem)))
return PoisonValue::get(RetTy);
auto *InVecTy = cast<VectorType>(Op0->getType());
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 99e9ecb01dd75..79723c9815445 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -457,7 +457,7 @@ bool llvm::getShuffleDemandedElts(int SrcWidth, ArrayRef<int> Mask,
return true;
// Simple case of a shuffle with zeroinitializer.
- if (all_of(Mask, [](int Elt) { return Elt == 0; })) {
+ if (all_of(Mask, equal_to(0))) {
DemandedLHS.setBit(0);
return true;
}
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 65b5965d99c18..28662665e86fa 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2965,7 +2965,7 @@ bool CodeGenPrepare::dupRetToEnableTailCallOpts(BasicBlock *BB,
EVI = dyn_cast<ExtractValueInst>(V);
if (EVI) {
V = EVI->getOperand(0);
- if (!llvm::all_of(EVI->indices(), [](unsigned idx) { return idx == 0; }))
+ if (!llvm::all_of(EVI->indices(), equal_to(0)))
return false;
}
diff --git a/llvm/lib/CodeGen/InterleavedAccessPass.cpp b/llvm/lib/CodeGen/InterleavedAccessPass.cpp
index 5c27a20869f81..eac6fbd492024 100644
--- a/llvm/lib/CodeGen/InterleavedAccessPass.cpp
+++ b/llvm/lib/CodeGen/InterleavedAccessPass.cpp
@@ -669,7 +669,7 @@ static std::pair<Value *, APInt> getMask(Value *WideMask, unsigned Factor,
SmallVector<unsigned> StartIndexes;
if (ShuffleVectorInst::isInterleaveMask(SVI->getShuffleMask(), Factor,
NumSrcElts * 2, StartIndexes) &&
- llvm::all_of(StartIndexes, [](unsigned Start) { return Start == 0; }) &&
+ llvm::all_of(StartIndexes, equal_to(0)) &&
llvm::all_of(SVI->getShuffleMask(), [&NumSrcElts](int Idx) {
return Idx < (int)NumSrcElts;
})) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 820b444f56eb1..efa446c48afa0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -27501,7 +27501,7 @@ static SDValue formSplatFromShuffles(ShuffleVectorSDNode *OuterShuf,
CombinedMask[i] = InnerMaskElt;
}
- assert((all_of(CombinedMask, [](int M) { return M == -1; }) ||
+ assert((all_of(CombinedMask, equal_to(-1)) ||
getSplatIndex(CombinedMask) != -1) &&
"Expected a splat mask");
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index bc8a97cbcc024..0739e8e73dfc2 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4161,8 +4161,7 @@ void SelectionDAGBuilder::visitShuffleVector(const User &I) {
EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType());
EVT SrcVT = Src1.getValueType();
- if (all_of(Mask, [](int Elem) { return Elem == 0; }) &&
- VT.isScalableVector()) {
+ if (all_of(Mask, equal_to(0)) && VT.isScalableVector()) {
// Canonical splat form of first element of first input vector.
SDValue FirstElt =
DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, SrcVT.getScalarType(), Src1,
diff --git a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
index 6db8b711f0a0e..21dc8c528311c 100644
--- a/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp
@@ -547,7 +547,7 @@ std::optional<uint64_t> MarkupFilter::parseAddr(StringRef Str) const {
reportTypeError(Str, "address");
return std::nullopt;
}
- if (all_of(Str, [](char C) { return C == '0'; }))
+ if (all_of(Str, equal_to('0')))
return 0;
if (!Str.starts_with("0x")) {
reportTypeError(Str, "address");
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 5cf9532a988fe..cbdd444f15d85 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -525,9 +525,9 @@ static void printShuffleMask(raw_ostream &Out, Type *Ty, ArrayRef<int> Mask) {
if (isa<ScalableVectorType>(Ty))
Out << "vscale x ";
Out << Mask.size() << " x i32> ";
- if (all_of(Mask, [](int Elt) { return Elt == 0; })) {
+ if (all_of(Mask, equal_to(0))) {
Out << "zeroinitializer";
- } else if (all_of(Mask, [](int Elt) { return Elt == PoisonMaskElem; })) {
+ } else if (all_of(Mask, equal_to(PoisonMaskElem))) {
Out << "poison";
} else {
Out << "<";
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 6a9ef2efa321f..72d627886fd0a 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -446,13 +446,13 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
Type *EltTy = V1VTy->getElementType();
// Poison shuffle mask -> poison value.
- if (all_of(Mask, [](int Elt) { return Elt == PoisonMaskElem; })) {
+ if (all_of(Mask, equal_to(PoisonMaskElem))) {
return PoisonValue::get(VectorType::get(EltTy, MaskEltCount));
}
// If the mask is all zeros this is a splat, no need to go through all
// elements.
- if (all_of(Mask, [](int Elt) { return Elt == 0; })) {
+ if (all_of(Mask, equal_to(0))) {
Type *Ty = IntegerType::get(V1->getContext(), 32);
Constant *Elt =
ConstantExpr::getExtractElement(V1, ConstantInt::get(Ty, 0));
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 2f020274c305a..eaba9c7d10178 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -752,7 +752,7 @@ static bool constantIsDead(const Constant *C, bool RemoveDeadUsers) {
ReplaceableMetadataImpl::SalvageDebugInfo(*C);
const_cast<Constant *>(C)->destroyConstant();
}
-
+
return true;
}
@@ -1760,8 +1760,7 @@ Constant *Constant::getSplatValue(bool AllowPoison) const {
Constant *SplatVal = IElt->getOperand(1);
ConstantInt *Index = dyn_cast<ConstantInt>(IElt->getOperand(2));
- if (Index && Index->getValue() == 0 &&
- llvm::all_of(Mask, [](int I) { return I == 0; }))
+ if (Index && Index->getValue() == 0 && llvm::all_of(Mask, equal_to(0)))
return SplatVal;
}
}
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 97bf63a404ec0..be307cf08ccc5 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -2318,7 +2318,7 @@ bool ShuffleVectorInst::isOneUseSingleSourceMask(ArrayRef<int> Mask, int VF) {
return false;
for (unsigned K = 0, Sz = Mask.size(); K < Sz; K += VF) {
ArrayRef<int> SubMask = Mask.slice(K, VF);
- if (all_of(SubMask, [](int Idx) { return Idx == PoisonMaskElem; }))
+ if (all_of(SubMask, equal_to(PoisonMaskElem)))
continue;
SmallBitVector Used(VF, false);
for (int Idx : SubMask) {
diff --git a/llvm/lib/IR/ProfDataUtils.cpp b/llvm/lib/IR/ProfDataUtils.cpp
index d1ada00fb1f64..1d6a7df5e91da 100644
--- a/llvm/lib/IR/ProfDataUtils.cpp
+++ b/llvm/lib/IR/ProfDataUtils.cpp
@@ -310,7 +310,7 @@ bool llvm::hasExplicitlyUnknownBranchWeights(const Instruction &I) {
void llvm::setBranchWeights(Instruction &I, ArrayRef<uint32_t> Weights,
bool IsExpected, bool ElideAllZero) {
if ((ElideAllZeroBranchWeights && ElideAllZero) &&
- llvm::all_of(Weights, [](uint32_t V) { return V == 0; })) {
+ llvm::all_of(Weights, equal_to(0))) {
I.setMetadata(LLVMContext::MD_prof, nullptr);
return;
}
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index e2645fa46bbcd..d4430705fe399 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -3946,8 +3946,7 @@ void IEEEFloat::initFromIEEEAPInt(const APInt &api) {
sign = static_cast<unsigned int>(last_word >> ((S.sizeInBits - 1) % 64));
- bool all_zero_significand =
- llvm::all_of(mysignificand, [](integerPart bits) { return bits == 0; });
+ bool all_zero_significand = llvm::all_of(mysignificand, equal_to(0));
bool is_zero = myexponent == 0 && all_zero_significand;
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 74ee8ff8ab5f5..91f7e2e9b8463 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -18462,7 +18462,7 @@ bool AArch64TargetLowering::lowerInterleavedStore(Instruction *Store,
// Sanity check if all the indices are NOT in range.
// If mask is `poison`, `Mask` may be a vector of -1s.
// If all of them are `poison`, OOB read will happen later.
- if (llvm::all_of(Mask, [](int Idx) { return Idx == PoisonMaskElem; })) {
+ if (llvm::all_of(Mask, equal_to(PoisonMaskElem))) {
return false;
}
// A 64bit st2 which does not start at element 0 will involved adding extra
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index c1c8c861cc55e..5e890f6067e82 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -647,7 +647,7 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
// v2i64 types get converted to cmp+bif hence the cost of 2
if (LT.second == MVT::v2i64)
return LT.first * 2;
- if (any_of(ValidMinMaxTys, [<](MVT M) { return M == LT.second; }))
+ if (any_of(ValidMinMaxTys, equal_to(LT.second)))
return LT.first;
break;
}
@@ -663,7 +663,7 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
// need to extend the type, as it uses shr(qadd(shl, shl)).
unsigned Instrs =
LT.second.getScalarSizeInBits() == RetTy->getScalarSizeInBits() ? 1 : 4;
- if (any_of(ValidSatTys, [<](MVT M) { return M == LT.second; }))
+ if (any_of(ValidSatTys, equal_to(LT.second)))
return LT.first * Instrs;
TypeSize TS = getDataLayout().getTypeSizeInBits(RetTy);
@@ -679,7 +679,7 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
MVT::v8i16, MVT::v2i32, MVT::v4i32,
MVT::v2i64};
auto LT = getTypeLegalizationCost(RetTy);
- if (any_of(ValidAbsTys, [<](MVT M) { return M == LT.second; }))
+ if (any_of(ValidAbsTys, equal_to(LT.second)))
return LT.first;
break;
}
@@ -687,7 +687,7 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
static const auto ValidAbsTys = {MVT::v4i16, MVT::v8i16, MVT::v2i32,
MVT::v4i32, MVT::v2i64};
auto LT = getTypeLegalizationCost(RetTy);
- if (any_of(ValidAbsTys, [<](MVT M) { return M == LT.second; }) &&
+ if (any_of(ValidAbsTys, equal_to(LT.second)) &&
LT.second.getScalarSizeInBits() == RetTy->getScalarSizeInBits())
return LT.first;
break;
@@ -4660,9 +4660,9 @@ InstructionCost AArch64TTIImpl::getCmpSelInstrCost(
static const auto ValidFP16MinMaxTys = {MVT::v4f16, MVT::v8f16};
auto LT = getTypeLegalizationCost(ValTy);
- if (any_of(ValidMinMaxTys, [<](MVT M) { return M == LT.second; }) ||
+ if (any_of(ValidMinMaxTys, equal_to(LT.second)) ||
(ST->hasFullFP16() &&
- any_of(ValidFP16MinMaxTys, [<](MVT M) { return M == LT.second; })))
+ any_of(ValidFP16MinMaxTys, equal_to(LT.second))))
return LT.first;
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index 35406a387cf0f..ed1fff970b1d2 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -804,7 +804,7 @@ GCNTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
InstRate = getFullRateInstrCost();
static const auto ValidSatTys = {MVT::v2i16, MVT::v4i16};
- if (any_of(ValidSatTys, [<](MVT M) { return M == LT.second; }))
+ if (any_of(ValidSatTys, equal_to(LT.second)))
NElts = 1;
break;
}
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 20ba44e3b8e59..b3e834b66ad45 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -917,9 +917,7 @@ class WaitcntBrackets {
// Bitmask of the VmemTypes of VMEM instructions for this VGPR.
unsigned VMEMTypes = 0;
- bool empty() const {
- return all_of(Scores, [](unsigned K) { return K == 0; }) && !VMEMTypes;
- }
+ bool empty() const { return all_of(Scores, equal_to(0)) && !VMEMTypes; }
};
struct SGPRInfo {
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index 4ad3a5cd1d727..a6017f57714d4 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -3698,9 +3698,9 @@ ClusterDimsAttr ClusterDimsAttr::get(const Function &F) {
if (!Attr.has_value())
AttrKind = Kind::Unknown;
- else if (all_of(*Attr, [](unsigned V) { return V == EncoNoCluster; }))
+ else if (all_of(*Attr, equal_to(EncoNoCluster)))
AttrKind = Kind::NoCluster;
- else if (all_of(*Attr, [](unsigned V) { return V == EncoVariableDims; }))
+ else if (all_of(*Attr, equal_to(EncoVariableDims)))
AttrKind = Kind::VariableDims;
ClusterDimsAttr A(AttrKind);
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 9bbb3aad89c44..6531c49a22b86 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -442,14 +442,14 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F,
O << ".explicitcluster\n";
if (ClusterDim[0] != 0) {
- assert(llvm::all_of(ClusterDim, [](unsigned D) { return D != 0; }) &&
+ assert(llvm::all_of(ClusterDim, not_equal_to(0)) &&
"cluster_dim_x != 0 implies cluster_dim_y and cluster_dim_z "
"should be non-zero as well");
O << formatv(".reqnctapercluster {0:$[, ]}\n",
make_range(ClusterDim.begin(), ClusterDim.end()));
} else {
- assert(llvm::all_of(ClusterDim, [](unsigned D) { return D == 0; }) &&
+ assert(llvm::all_of(ClusterDim, equal_to(0)) &&
"cluster_dim_x == 0 implies cluster_dim_y and cluster_dim_z "
"should be 0 as well");
}
diff --git a/llvm/lib/Target/NVPTX/NVPTXUtilities.h b/llvm/lib/Target/NVPTX/NVPTXUtilities.h
index 21d7768af3d06..1cdc21cc44d5a 100644
--- a/llvm/lib/Target/NVPTX/NVPTXUtilities.h
+++ b/llvm/lib/Target/NVPTX/NVPTXUtilities.h
@@ -104,7 +104,7 @@ inline auto packed_types() {
// Checks if the type VT can fit into a single register.
inline bool isPackedVectorTy(EVT VT) {
- return any_of(packed_types(), [VT](EVT OVT) { return OVT == VT; });
+ return any_of(packed_types(), equal_to(VT));
}
// Checks if two or more of the type ET can fit into a single register.
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index 74bef26984089..a9814655d79a4 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -190,7 +190,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
auto M = partition(Tokens, [](auto &&T) { return T.starts_with('+'); });
- if (std::any_of(M, Tokens.end(), [](auto &&T) { return T == "all"; }))
+ if (std::any_of(M, Tokens.end(), equal_to("all")))
copy(make_second_range(SPIRVExtensionMap), std::inserter(Vals, Vals.end()));
for (auto &&Token : make_range(Tokens.begin(), M)) {
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 7f64255e23a59..aa890ae18c88c 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3798,8 +3798,7 @@ static bool isUndefOrZero(int Val) {
/// Return true if every element in Mask, beginning from position Pos and ending
/// in Pos+Size is the undef sentinel value.
static bool isUndefInRange(ArrayRef<int> Mask, unsigned Pos, unsigned Size) {
- return llvm::all_of(Mask.slice(Pos, Size),
- [](int M) { return M == SM_SentinelUndef; });
+ return llvm::all_of(Mask.slice(Pos, Size), equal_to(SM_SentinelUndef));
}
/// Return true if the mask creates a vector whose lower half is undefined.
@@ -3827,7 +3826,7 @@ static bool isAnyInRange(ArrayRef<int> Mask, int Low, int Hi) {
/// Return true if the value of any element in Mask is the zero sentinel value.
static bool isAnyZero(ArrayRef<int> Mask) {
- return llvm::any_of(Mask, [](int M) { return M == SM_SentinelZero; });
+ return llvm::any_of(Mask, equal_to(SM_SentinelZero));
}
/// Return true if Val is undef or if its value falls within the
@@ -41672,7 +41671,7 @@ static SDValue combineX86ShufflesRecursively(
resolveTargetShuffleInputsAndMask(Ops, Mask);
// Handle the all undef/zero/ones cases early.
- if (all_of(Mask, [](int Idx) { return Idx == SM_SentinelUndef; }))
+ if (all_of(Mask, equal_to(SM_SentinelUndef)))
return DAG.getUNDEF(RootVT);
if (all_of(Mask, [](int Idx) { return Idx < 0; }))
return getZeroVector(RootVT, Subtarget, DAG, DL);
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 9fb97918cb71a..608727b745925 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -1799,7 +1799,7 @@ InstructionCost X86TTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
return;
}
if (SrcReg != DestReg &&
- any_of(RegMask, [](int I) { return I != PoisonMaskElem; })) {
+ any_of(RegMask, not_equal_to(PoisonMaskElem))) {
// Just a copy of the source register.
Cost += TTI::TCC_Free;
}
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 3d51c5d986ef6..58499bdd0f8e9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1641,7 +1641,7 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
->getNumElements();
// Handle trivial case of a splat. Only check the first element of LHS
// operand.
- if (all_of(Shuffle->getShuffleMask(), [](int Elt) { return Elt == 0; }) &&
+ if (all_of(Shuffle->getShuffleMask(), equal_to(0)) &&
DemandedElts.isAllOnes()) {
if (!isa<PoisonValue>(I->getOperand(1))) {
I->setOperand(1, PoisonValue::get(I->getOperand(1)->getType()));
diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
index 0acbaf58a8f74..3022f4a8481d0 100644
--- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -822,7 +822,7 @@ void GVNHoist::fillChiArgs(BasicBlock *BB, OutValuesType &CHIBBs,
<< ", VN: " << C.VN.first << ", " << C.VN.second);
}
// Move to next CHI of a different value
- It = std::find_if(It, VCHI.end(), [It](CHIArg &A) { return A != *It; });
+ It = std::find_if(It, VCHI.end(), not_equal_to(*It));
} else
++It;
}
@@ -846,7 +846,7 @@ void GVNHoist::findHoistableCandidates(OutValuesType &CHIBBs,
auto TI = BB->getTerminator();
auto B = CHIs.begin();
// [PreIt, PHIIt) form a range of CHIs which have identical VNs.
- auto PHIIt = llvm::find_if(CHIs, [B](CHIArg &A) { return A != *B; });
+ auto PHIIt = llvm::find_if(CHIs, not_equal_to(*B));
auto PrevIt = CHIs.begin();
while (PrevIt != PHIIt) {
// Collect values which satisfy safety checks.
@@ -1001,7 +1001,7 @@ void GVNHoist::raMPHIuw(MemoryUseOrDef *NewMemAcc) {
for (MemoryPhi *Phi : UsePhis) {
auto In = Phi->incoming_values();
- if (llvm::all_of(In, [&](Use &U) { return U == NewMemAcc; })) {
+ if (llvm::all_of(In, equal_to(NewMemAcc))) {
Phi->replaceAllUsesWith(NewMemAcc);
MSSAUpdater->removeMemoryAccess(Phi);
}
diff --git a/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp b/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
index 6fb81976c9e6e..291f9b2502948 100644
--- a/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpTableToSwitch.cpp
@@ -184,7 +184,7 @@ expandToSwitch(CallBase *CB, const JumpTableTy &JT, DomTreeUpdater &DTU,
});
if (HadProfile && !ProfcheckDisableMetadataFixes) {
// At least one of the targets must've been taken.
- assert(llvm::any_of(BranchWeights, [](uint64_t V) { return V != 0; }));
+ assert(llvm::any_of(BranchWeights, not_equal_to(0)));
setBranchWeights(*Switch, downscaleWeights(BranchWeights),
/*IsExpected=*/false);
} else
diff --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index c59816e56431f..f944621ba4744 100644
--- a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
@@ -263,7 +263,7 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level,
// If all the elements of any direction vector have only '*', legality
// can't be proven. Exit early to save compile time.
- if (all_of(Dep, [](char C) { return C == '*'; })) {
+ if (all_of(Dep, equal_to('*'))) {
ORE->emit([&]() {
return OptimizationRemarkMissed(DEBUG_TYPE, "Dependence",
L->getStartLoc(), L->getHeader())
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 5a8f18a60da25..9917c47cb6770 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1804,7 +1804,7 @@ NewGVN::performSymbolicPHIEvaluation(ArrayRef<ValPair> PHIOps,
Value *AllSameValue = *(Filtered.begin());
++Filtered.begin();
// Can't use std::equal here, sadly, because filter.begin moves.
- if (llvm::all_of(Filtered, [&](Value *Arg) { return Arg == AllSameValue; })) {
+ if (llvm::all_of(Filtered, equal_to(AllSameValue))) {
// Can't fold phi(undef, X) -> X unless X can't be poison (thus X is undef
// in the worst case).
if (HasUndef && !isGuaranteedNotToBePoison(AllSameValue, AC, nullptr, DT))
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 3cb3018a70559..4ef6e2516c5da 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -7817,7 +7817,7 @@ static bool simplifySwitchOfPowersOfTwo(SwitchInst *SI, IRBuilder<> &Builder,
auto HasWeights =
!ProfcheckDisableMetadataFixes && extractBranchWeights(*SI, Weights);
auto *BI = BranchInst::Create(SplitBB, DefaultCaseBB, IsPow2, It);
- if (HasWeights && any_of(Weights, [](const auto &V) { return V != 0; })) {
+ if (HasWeights && any_of(Weights, not_equal_to(0))) {
// IsPow2 covers a subset of the cases in which we'd go to the default
// label. The other is those powers of 2 that don't appear in the case
// statement. We don't know the distribution of the values coming in, so
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e075268a0a8e9..e352e934a7379 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6437,7 +6437,7 @@ BoUpSLP::findReusedOrderedScalars(const BoUpSLP::TreeEntry &TE,
unsigned Limit = getNumElems(CurrentOrder.size(), PartSz, I);
MutableArrayRef<unsigned> Slice = CurrentOrder.slice(I * PartSz, Limit);
// Shuffle of at least 2 vectors - ignore.
- if (any_of(Slice, [&](unsigned I) { return I != NumScalars; })) {
+ if (any_of(Slice, not_equal_to(NumScalars))) {
llvm::fill(Slice, NumScalars);
ShuffledSubMasks.set(I);
continue;
@@ -12673,7 +12673,7 @@ class BaseShuffleAnalysis {
// <poison,poison,poison,poison,0,1,2,poison,poison,1,2,3> etc. for VF 4).
if (Limit % VF == 0 && all_of(seq<int>(0, Limit / VF), [=](int Idx) {
ArrayRef<int> Slice = Mask.slice(Idx * VF, VF);
- return all_of(Slice, [](int I) { return I == PoisonMaskElem; }) ||
+ return all_of(Slice, equal_to(PoisonMaskElem)) ||
ShuffleVectorInst::isIdentityMask(Slice, VF);
}))
return true;
@@ -14482,8 +14482,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
auto *MaskVecTy = getWidenedType(ScalarTy, Mask.size());
unsigned NumParts = ::getNumberOfParts(TTI, MaskVecTy, Mask.size());
unsigned SliceSize = getPartNumElems(Mask.size(), NumParts);
- const auto *It =
- find_if(Mask, [](int Idx) { return Idx != PoisonMaskElem; });
+ const auto *It = find_if(Mask, not_equal_to(PoisonMaskElem));
unsigned Part = std::distance(Mask.begin(), It) / SliceSize;
estimateNodesPermuteCost(E1, &E2, Mask, Part, SliceSize);
}
@@ -14497,8 +14496,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
auto *MaskVecTy = getWidenedType(ScalarTy, Mask.size());
unsigned NumParts = ::getNumberOfParts(TTI, MaskVecTy, Mask.size());
unsigned SliceSize = getPartNumElems(Mask.size(), NumParts);
- const auto *It =
- find_if(Mask, [](int Idx) { return Idx != PoisonMaskElem; });
+ const auto *It = find_if(Mask, not_equal_to(PoisonMaskElem));
unsigned Part = std::distance(Mask.begin(), It) / SliceSize;
estimateNodesPermuteCost(E1, nullptr, Mask, Part, SliceSize);
if (!SameNodesEstimated && InVectors.size() == 1)
@@ -17330,7 +17328,7 @@ BoUpSLP::tryToGatherSingleRegisterExtractElements(
// shuffle of a single/two vectors the scalars are extracted from.
std::optional<TTI::ShuffleKind> Res =
isFixedVectorShuffle(GatheredExtracts, Mask, AC);
- if (!Res || all_of(Mask, [](int Idx) { return Idx == PoisonMaskElem; })) {
+ if (!Res || all_of(Mask, equal_to(PoisonMaskElem))) {
// TODO: try to check other subsets if possible.
// Restore the original VL if attempt was not successful.
copy(SavedVL, VL.begin());
@@ -19675,8 +19673,7 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Type *ScalarTy,
NewMask, CostKind);
InstructionCost BVCost = TTI->getVectorInstrCost(
Instruction::InsertElement, VecTy, CostKind,
- *find_if(Mask, [](int I) { return I != PoisonMaskElem; }),
- Vec, V);
+ *find_if(Mask, not_equal_to(PoisonMaskElem)), Vec, V);
// Shuffle required?
if (count(BVMask, PoisonMaskElem) <
static_cast<int>(BVMask.size() - 1)) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index b41e04cff6d83..fb18b60596501 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -5042,8 +5042,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
// ops.
auto *Member0 = InterleaveR->getStoredValues()[0];
if (isAlreadyNarrow(Member0) &&
- all_of(InterleaveR->getStoredValues(),
- [Member0](VPValue *VPV) { return Member0 == VPV; })) {
+ all_of(InterleaveR->getStoredValues(), equal_to(Member0))) {
StoreGroups.push_back(InterleaveR);
continue;
}
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 9a33b1890eca0..708763a7eb982 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -3958,8 +3958,7 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
if (!ShouldBeCallOrBinInst)
return false;
- if (!IsFirstCallOrBinInst &&
- any_of(PrevVecV, [](Value *VecV) { return VecV == nullptr; }))
+ if (!IsFirstCallOrBinInst && any_of(PrevVecV, equal_to(nullptr)))
return false;
// For the first found call/bin op, the vector has to come from the
@@ -4006,8 +4005,7 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
if (!ShouldBeCallOrBinInst)
return false;
- if (!IsFirstCallOrBinInst &&
- any_of(PrevVecV, [](Value *VecV) { return VecV == nullptr; }))
+ if (!IsFirstCallOrBinInst && any_of(PrevVecV, equal_to(nullptr)))
return false;
if (BinOp != (IsFirstCallOrBinInst ? VecOpEE : PrevVecV[0]))
@@ -4047,8 +4045,7 @@ bool VectorCombine::foldShuffleChainsToReduce(Instruction &I) {
} else if (auto *SVInst = dyn_cast<ShuffleVectorInst>(CI)) {
// We shouldn't have any null values in the previous vectors,
// is so, there was a mismatch in pattern.
- if (ShouldBeCallOrBinInst ||
- any_of(PrevVecV, [](Value *VecV) { return VecV == nullptr; }))
+ if (ShouldBeCallOrBinInst || any_of(PrevVecV, equal_to(nullptr)))
return false;
if (SVInst != PrevVecV[1])
More information about the llvm-commits
mailing list