This is an archive of the discontinued LLVM Phabricator instance.

LoopVectorize: vectorize finding first IV in select-cmp
AbandonedPublic

Authored by artagnon on Aug 14 2023, 5:53 AM.

Details

Summary

Extend the idea in D150851 to introduce RecurKinds [I|F]FindFirstIV
corresponding to [I|F]FirstLastIV. D150851 enabled vectorization of the
following example:

long src[20000] = {4, 5, 2};
long r = 331;
for (long i = 0; i < 20000; i++) {
  if (src[i] > 3)
    r = i;
}
return r;

This patch extends the above idea to also vectorize:

long src[20000] = {4, 5, 2};
long r = 331;
for (long i = 20000 - 1; i >= 0; i--) {
  if (src[i] > 3)
    r = i;
}
return r;

Diff Detail

Event Timeline

artagnon created this revision.Aug 14 2023, 5:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 5:53 AM
artagnon requested review of this revision.Aug 14 2023, 5:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2023, 5:53 AM
Mel-Chen added inline comments.Aug 22 2023, 3:09 AM
llvm/include/llvm/Analysis/IVDescriptors.h
63–67

I prefer FindLastIncIV and FindLastDecIV. The term 'Last' should refer to the last iteration in the loop, and 'first' should refer to the first iteration in the loop.

llvm/lib/Analysis/IVDescriptors.cpp
428–432

I updated here. Please rebase on the last version.

620

How about name to LoopInductionDirection?

artagnon abandoned this revision.Sep 25 2023, 5:02 AM

Will migrate to Github PR once D150851 is migrated.