[PATCH] D126476: [SLP]Improve compile time, NFC.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 08:05:45 PDT 2022
ABataev created this revision.
ABataev added a reviewer: RKSimon.
Herald added subscribers: vporpo, hiraditya.
Herald added a project: All.
ABataev requested review of this revision.
Herald added a project: LLVM.
Patch improves compile time. For function calls, which cannot be
vectorized, create a unique group for each such a call instead of
subgroup. It prevents them from being grouped by a subgroups and
attempts for their vectorization.
Also, looks through casts operand to try to check their
groups/subgroups.
Reduces number of vectorization attempts. No changes in the statistics
for SPEC2017/2006/llvm-test-suite.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126476
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4430,6 +4430,14 @@
hash_value(isa<BinaryOperator>(I)
? I->getType()
: cast<CastInst>(I)->getOperand(0)->getType()));
+ // For casts, look through the only operand to improve compile time.
+ if (isa<CastInst>(I)) {
+ std::pair<size_t, size_t> OpVals =
+ generateKeySubkey(I->getOperand(0), TLI, LoadsSubkeyGenerator,
+ /*=AllowAlternate*/ true);
+ Key = hash_combine(OpVals.first, Key);
+ SubKey = hash_combine(OpVals.first, SubKey);
+ }
} else if (auto *CI = dyn_cast<CmpInst>(I)) {
CmpInst::Predicate Pred = CI->getPredicate();
if (CI->isCommutative())
@@ -4440,13 +4448,15 @@
hash_value(CI->getOperand(0)->getType()));
} else if (auto *Call = dyn_cast<CallInst>(I)) {
Intrinsic::ID ID = getVectorIntrinsicIDForCall(Call, TLI);
- if (isTriviallyVectorizable(ID))
+ if (isTriviallyVectorizable(ID)) {
SubKey = hash_combine(hash_value(I->getOpcode()), hash_value(ID));
- else if (!VFDatabase(*Call).getMappings(*Call).empty())
+ } else if (!VFDatabase(*Call).getMappings(*Call).empty()) {
SubKey = hash_combine(hash_value(I->getOpcode()),
hash_value(Call->getCalledFunction()));
- else
+ } else {
+ Key = hash_combine(hash_value(Call), Key);
SubKey = hash_combine(hash_value(I->getOpcode()), hash_value(Call));
+ }
for (const CallBase::BundleOpInfo &Op : Call->bundle_op_infos())
SubKey = hash_combine(hash_value(Op.Begin), hash_value(Op.End),
hash_value(Op.Tag), SubKey);
@@ -10636,12 +10646,16 @@
std::tie(Key, Idx) = generateKeySubkey(
V, &TLI,
[&PossibleReducedVals, &DL, &SE](size_t Key, LoadInst *LI) {
- for (const auto &LoadData : PossibleReducedVals[Key]) {
- auto *RLI = cast<LoadInst>(LoadData.second.front().first);
- if (getPointersDiff(RLI->getType(), RLI->getPointerOperand(),
- LI->getType(), LI->getPointerOperand(),
- DL, SE, /*StrictCheck=*/true))
- return hash_value(RLI->getPointerOperand());
+ auto It = PossibleReducedVals.find(Key);
+ if (It != PossibleReducedVals.end()) {
+ for (const auto &LoadData : It->second) {
+ auto *RLI = cast<LoadInst>(LoadData.second.front().first);
+ if (getPointersDiff(RLI->getType(),
+ RLI->getPointerOperand(), LI->getType(),
+ LI->getPointerOperand(), DL, SE,
+ /*StrictCheck=*/true))
+ return hash_value(RLI->getPointerOperand());
+ }
}
return hash_value(LI->getPointerOperand());
},
@@ -10657,12 +10671,15 @@
std::tie(Key, Idx) = generateKeySubkey(
TreeN, &TLI,
[&PossibleReducedVals, &DL, &SE](size_t Key, LoadInst *LI) {
- for (const auto &LoadData : PossibleReducedVals[Key]) {
- auto *RLI = cast<LoadInst>(LoadData.second.front().first);
- if (getPointersDiff(RLI->getType(), RLI->getPointerOperand(),
- LI->getType(), LI->getPointerOperand(), DL,
- SE, /*StrictCheck=*/true))
- return hash_value(RLI->getPointerOperand());
+ auto It = PossibleReducedVals.find(Key);
+ if (It != PossibleReducedVals.end()) {
+ for (const auto &LoadData : It->second) {
+ auto *RLI = cast<LoadInst>(LoadData.second.front().first);
+ if (getPointersDiff(RLI->getType(), RLI->getPointerOperand(),
+ LI->getType(), LI->getPointerOperand(),
+ DL, SE, /*StrictCheck=*/true))
+ return hash_value(RLI->getPointerOperand());
+ }
}
return hash_value(LI->getPointerOperand());
},
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126476.432289.patch
Type: text/x-patch
Size: 4556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220526/d33c4dd4/attachment.bin>
More information about the llvm-commits
mailing list