[PATCH] SLPVectorizer: limit the number of alias checks to reduce the runtime.
Arnold
aschwaighofer at apple.com
Thu Jan 15 08:00:50 PST 2015
I think that this should be a global at the top of the file so that it is more visible to folks would want to experiment with thresholds.
Maybe we could also make the name reflect that is only counting the failed alias checks: FailedAliasChecksLimit or so.
Otherwise, LGTM.
Sent from my iPhone
> On Jan 15, 2015, at 7:47 AM, Erik Eckstein <eeckstein at apple.com> wrote:
>
> Hi aschwaighofer,
>
> Beside caching the alias results, this is another step to reduce the SLPVectorizer's runtime.
> In case of blocks with many memory-accessing instructions, alias checking can take lot of time (because calculating the memory dependencies has quadratic complexity).
> I chose a limit which resulted in no changes when running the benchmarks.
>
> 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
> @@ -2755,10 +2755,24 @@
> AliasAnalysis::Location SrcLoc = getLocation(SrcInst, SLP->AA);
> bool SrcMayWrite = BundleMember->Inst->mayWriteToMemory();
>
> + // Limit the number of alias checks, becaus SLP->isAliased() is the
> + // expensive part in the following loop. The limit is chosen so that
> + // it has no negative effect on the llvm benchmarks.
> + int AliasCheckLimit = 10;
> + int numAliased = 0;
> +
> while (DepDest) {
> assert(isInSchedulingRegion(DepDest));
> if (SrcMayWrite || DepDest->Inst->mayWriteToMemory()) {
> - if (SLP->isAliased(SrcLoc, SrcInst, DepDest->Inst)) {
> +
> + if (numAliased >= AliasCheckLimit
> + || 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/
> <D6999.18229.patch>
More information about the llvm-commits
mailing list