[PATCH] D110623: [SLP] Avoid calculating expensive spill cost when it is not required
Dinar Temirbulatov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 18 08:05:13 PST 2022
dtemirbulatov updated this revision to Diff 400851.
dtemirbulatov added a comment.
Rebase, I decided to stick with isAssumeLikeIntrinsic() and avoid just checking for any intrinsic since there might be special embedded targets where intrinsic might end up in an actual call to a function.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110623/new/
https://reviews.llvm.org/D110623
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
@@ -2489,6 +2489,7 @@
// Make a new scheduling region, i.e. all existing ScheduleData is not
// in the new region yet.
++SchedulingRegionID;
+ NoCalls = true;
}
ScheduleData *getScheduleData(Value *V) {
@@ -2706,6 +2707,10 @@
// Make sure that the initial SchedulingRegionID is greater than the
// initial SchedulingRegionID in ScheduleData (which is 0).
int SchedulingRegionID = 1;
+
+ /// Indicates that no CallInst found in the tree and we don't need to
+ /// calculate spill cost.
+ bool NoCalls = true;
};
/// Attaches the BlockScheduling structures to basic blocks.
@@ -5569,10 +5574,13 @@
}
// Debug information does not impact spill cost.
- if ((isa<CallInst>(&*PrevInstIt) &&
- !isa<DbgInfoIntrinsic>(&*PrevInstIt)) &&
- &*PrevInstIt != PrevInst)
- NumCalls++;
+ if (isa<CallInst>(&*PrevInstIt)) {
+ auto *II = dyn_cast<IntrinsicInst>(&*PrevInstIt);
+ if (!isa<DbgInfoIntrinsic>(&*PrevInstIt) &&
+ !(&*PrevInstIt)->isLifetimeStartOrEnd() &&
+ (!II || !II->isAssumeLikeIntrinsic()))
+ NumCalls++;
+ }
++PrevInstIt;
}
@@ -5736,7 +5744,13 @@
}
}
- InstructionCost SpillCost = getSpillCost();
+ bool NoCallInst = all_of(BlocksSchedules,
+ [](const decltype(BlocksSchedules)::value_type &BS) {
+ return BS.second->NoCalls;
+ });
+
+ InstructionCost SpillCost = NoCallInst ? 0 : getSpillCost();
+ assert((!NoCallInst || getSpillCost() == 0) && "Incorrect spill cost");
Cost += SpillCost + ExtractCost;
if (FirstUsers.size() == 1) {
int Limit = ShuffleMask.front().size() * 2;
@@ -7472,6 +7486,12 @@
}
CurrentLoadStore = SD;
}
+ if (isa<CallInst>(I)) {
+ auto *II = dyn_cast<IntrinsicInst>(I);
+ if (!isa<DbgInfoIntrinsic>(I) && !I->isLifetimeStartOrEnd() &&
+ (!II || !II->isAssumeLikeIntrinsic()))
+ NoCalls = false;
+ }
}
if (NextLoadStore) {
if (CurrentLoadStore)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110623.400851.patch
Type: text/x-patch
Size: 2356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220118/088e5acb/attachment.bin>
More information about the llvm-commits
mailing list