[llvm] a9e6295 - [SLP][NFC]Use all_of/any_of instead of loops, NFC.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 22 08:27:27 PDT 2023
Author: Alexey Bataev
Date: 2023-08-22T08:21:36-07:00
New Revision: a9e6295548167c96617f5c17cc871fa3d61e79fb
URL: https://github.com/llvm/llvm-project/commit/a9e6295548167c96617f5c17cc871fa3d61e79fb
DIFF: https://github.com/llvm/llvm-project/commit/a9e6295548167c96617f5c17cc871fa3d61e79fb.diff
LOG: [SLP][NFC]Use all_of/any_of instead of loops, NFC.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0db8b53357f1a7..6c28f181146a58 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -885,12 +885,8 @@ static InstructionsState getSameOpcode(ArrayRef<Value *> VL,
/// \returns true if all of the values in \p VL have the same type or false
/// otherwise.
static bool allSameType(ArrayRef<Value *> VL) {
- Type *Ty = VL[0]->getType();
- for (int i = 1, e = VL.size(); i < e; i++)
- if (VL[i]->getType() != Ty)
- return false;
-
- return true;
+ Type *Ty = VL.front()->getType();
+ return all_of(VL.drop_front(), [&](Value *V) { return V->getType() == Ty; });
}
/// \returns True if in-tree use also needs extract. This refers to
@@ -910,11 +906,10 @@ static bool InTreeUserNeedToExtract(Value *Scalar, Instruction *UserInst,
case Instruction::Call: {
CallInst *CI = cast<CallInst>(UserInst);
Intrinsic::ID ID = getVectorIntrinsicIDForCall(CI, TLI);
- for (unsigned i = 0, e = CI->arg_size(); i != e; ++i) {
- if (isVectorIntrinsicWithScalarOpAtArg(ID, i))
- return (CI->getArgOperand(i) == Scalar);
- }
- [[fallthrough]];
+ return any_of(enumerate(CI->args()), [&](auto &&Arg) {
+ return isVectorIntrinsicWithScalarOpAtArg(ID, Arg.index()) &&
+ Arg.value().get() == Scalar;
+ });
}
default:
return false;
More information about the llvm-commits
mailing list