This is an archive of the discontinued LLVM Phabricator instance.

[LoopLoadElimination] Add support for stride equal to -1
ClosedPublic

Authored by igor.kirillov on May 25 2023, 7:24 AM.

Details

Summary

This patch allows us to gain all the benefits provided by
LoopLoadElimination pass to descending loops.

Diff Detail

Event Timeline

igor.kirillov created this revision.May 25 2023, 7:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 7:24 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
igor.kirillov requested review of this revision.May 25 2023, 7:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 7:24 AM

This patch aids in eliminating load within a complex loop in the benchmark. The GVN LoadPRE is unable to accomplish as the case is too difficult for it. A simplified example demonstrating this loop in the benchmark would be as follows:

void f(double *U, long long i, long long n) {
  #pragma clang loop vectorize(disable) unroll(disable)
  for (long long k = n; k > 0; --k)
    U[i * n + k] = U[i * n + k + 1];
}
nikic added a reviewer: fhahn.May 25 2023, 1:14 PM

Looks sensible to me, but I'm not very familiar with LAA.

mgabka added a subscriber: mgabka.May 25 2023, 1:44 PM
fhahn accepted this revision.May 31 2023, 12:20 PM

LGTM, thanks!

llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
91–93

nit: maybe absolute distance of one?

This revision is now accepted and ready to land.May 31 2023, 12:20 PM
igor.kirillov marked an inline comment as done.Jun 1 2023, 4:06 AM