Use llvm::all_equal (NFC)

This commit is contained in:
Kazu Hirata 2022-08-27 09:53:09 -07:00
parent b2c96d7855
commit a33ef8f2b7
9 changed files with 10 additions and 23 deletions

View File

@ -198,7 +198,7 @@ OffloadAction::OffloadAction(const DeviceDependences &DDeps, types::ID Ty)
auto &OTCs = DDeps.getToolChains();
// If all inputs agree on the same kind, use it also for this action.
if (llvm::all_of(OKinds, [&](OffloadKind K) { return K == OKinds.front(); }))
if (llvm::all_equal(OKinds))
OffloadingDeviceKind = OKinds.front();
// If we have a single dependency, inherit the architecture from it.

View File

@ -991,9 +991,7 @@ bool Driver::loadConfigFile() {
std::vector<std::string> ConfigFiles =
CLOptions->getAllArgValues(options::OPT_config);
if (ConfigFiles.size() > 1) {
if (!llvm::all_of(ConfigFiles, [ConfigFiles](const std::string &s) {
return s == ConfigFiles[0];
})) {
if (!llvm::all_equal(ConfigFiles)) {
Diag(diag::err_drv_duplicate_config);
return true;
}

View File

@ -804,10 +804,7 @@ llvm::Error AMDGPUToolChain::getSystemGPUArch(const ArgList &Args,
}
GPUArch = GPUArchs[0];
if (GPUArchs.size() > 1) {
bool AllSame = llvm::all_of(GPUArchs, [&](const StringRef &GPUArch) {
return GPUArch == GPUArchs.front();
});
if (!AllSame)
if (!llvm::all_equal(GPUArchs))
return llvm::createStringError(
std::error_code(), "Multiple AMD GPUs found with different archs");
}

View File

@ -755,7 +755,7 @@ static inline uint64_t decodeAdvSIMDModImmType12(uint8_t Imm) {
template <typename T>
static inline bool isSVEMaskOfIdenticalElements(int64_t Imm) {
auto Parts = bit_cast<std::array<T, sizeof(int64_t) / sizeof(T)>>(Imm);
return all_of(Parts, [&](T Elem) { return Elem == Parts[0]; });
return llvm::all_equal(Parts);
}
/// Returns true if Imm is valid for CPY/DUP.

View File

@ -53986,7 +53986,7 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, MVT VT,
return getZeroVector(VT, Subtarget, DAG, DL);
SDValue Op0 = Ops[0];
bool IsSplat = llvm::all_of(Ops, [&Op0](SDValue Op) { return Op == Op0; });
bool IsSplat = llvm::all_equal(Ops);
// Repeated subvectors.
if (IsSplat &&

View File

@ -1083,10 +1083,8 @@ void PartialInlinerImpl::FunctionCloner::normalizeReturnBlock() const {
return;
auto IsTrivialPhi = [](PHINode *PN) -> Value * {
Value *CommonValue = PN->getIncomingValue(0);
if (all_of(PN->incoming_values(),
[&](Value *V) { return V == CommonValue; }))
return CommonValue;
if (llvm::all_equal(PN->incoming_values()))
return PN->getIncomingValue(0);
return nullptr;
};

View File

@ -288,7 +288,7 @@ public:
ArrayRef<Value *> getValues() const { return Values; }
bool areAllIncomingValuesSame() const {
return llvm::all_of(Values, [&](Value *V) { return V == Values[0]; });
return llvm::all_equal(Values);
}
bool areAllIncomingValuesSameType() const {

View File

@ -8258,12 +8258,8 @@ VPRecipeOrVPValueTy VPRecipeBuilder::tryToBlend(PHINode *Phi,
VPlanPtr &Plan) {
// If all incoming values are equal, the incoming VPValue can be used directly
// instead of creating a new VPBlendRecipe.
VPValue *FirstIncoming = Operands[0];
if (all_of(Operands, [FirstIncoming](const VPValue *Inc) {
return FirstIncoming == Inc;
})) {
if (llvm::all_equal(Operands))
return Operands[0];
}
unsigned NumIncoming = Phi->getNumIncomingValues();
// For in-loop reductions, we do not need to create an additional select.

View File

@ -3,9 +3,7 @@ include "mlir/Dialect/Shape/IR/ShapeOps.td"
include "mlir/Dialect/Tensor/IR/TensorOps.td"
def AllInputShapesEq : Constraint<CPred< [{
llvm::all_of($0, [&](mlir::Value val) {
return $0[0] == val;
})
llvm::all_equal($0)
}]>>;
def HasSingleElement : Constraint<CPred< [{