[PATCH] SLPVectorizer: limit the number of alias checks to reduce the runtime.
Erik Eckstein
eeckstein at apple.com
Thu Jan 15 08:32:14 PST 2015
Arnold, thanks for your comments.
I renamed the const to "AliasedCheckLimit"
http://reviews.llvm.org/D6999
Files:
lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -75,6 +75,10 @@
static const unsigned RecursionMaxDepth = 12;
+// Limit the number of alias checks. The limit is chosen so that
+// it has no negative effect on the llvm benchmarks.
+static const unsigned AliasedCheckLimit = 10;
+
/// \returns the parent basic block if all of the instructions in \p VL
/// are in the same block or null otherwise.
static BasicBlock *getSameBlock(ArrayRef<Value *> VL) {
@@ -2754,11 +2758,22 @@
Instruction *SrcInst = BundleMember->Inst;
AliasAnalysis::Location SrcLoc = getLocation(SrcInst, SLP->AA);
bool SrcMayWrite = BundleMember->Inst->mayWriteToMemory();
+ unsigned numAliased = 0;
while (DepDest) {
assert(isInSchedulingRegion(DepDest));
if (SrcMayWrite || DepDest->Inst->mayWriteToMemory()) {
- if (SLP->isAliased(SrcLoc, SrcInst, DepDest->Inst)) {
+
+ // Limit the number of alias checks, becaus SLP->isAliased() is
+ // the expensive part in the following loop.
+ if (numAliased >= AliasedCheckLimit
+ || SLP->isAliased(SrcLoc, SrcInst, DepDest->Inst)) {
+
+ // We increment the counter only if the locations are aliased
+ // (instead of counting all alias checks). This gives a better
+ // balance between reduced runtime accurate dependencies.
+ numAliased++;
+
DepDest->MemoryDependencies.push_back(BundleMember);
BundleMember->Dependencies++;
ScheduleData *DestBundle = DepDest->FirstInBundle;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6999.18230.patch
Type: text/x-patch
Size: 1825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150115/f0c59184/attachment.bin>
More information about the llvm-commits
mailing list