This is an archive of the discontinued LLVM Phabricator instance.

[LoopAccesses 2/3] Allow querying of interesting dependences
ClosedPublic

Authored by anemet on Mar 6 2015, 10:22 AM.

Details

Summary

Gather an array of interesting dependences rather than just failing
after the first unsafe one and regarding the loop unsafe. Loop
Distribution needs to be able to collect all dependences in order to
isolate the dependence cycles into their own partition.

Since the dependence checking algorithm is quadratic in terms of
accesses sharing the same underlying pointer, I am applying a cut-off
threshold (MaxInterestingDependence). Exceeding that, the logic reverts
back to the original approach deeming the loop unsafe upon encountering
the first unsafe dependence.

The main idea of the patch is to split isDepedent from directly
answering the question whether the dep is safe for vectorization to
return a dependence type which then gets mapped to old boolean result
using Dependence::isSafeForVectorization.

Tested that this was compile-time neutral on SpecINT2006 LTO bitcode
inputs. No assembly change on the testsuite including external.

Diff Detail

Event Timeline

anemet updated this revision to Diff 21373.Mar 6 2015, 10:22 AM
anemet retitled this revision from to [LoopAccesses 2/3] Allow querying of interesting dependences.
anemet updated this object.
anemet edited the test plan for this revision. (Show Details)
anemet added reviewers: hfinkel, aschwaighofer, nadav.
anemet added a subscriber: Unknown Object (MLST).
anemet added inline comments.Mar 6 2015, 1:25 PM
include/llvm/Analysis/LoopAccessAnalysis.h
224–227

Please ignore this last declaration; it crept in from the memcheck patchset. Removed locally.

hfinkel added inline comments.Mar 7 2015, 10:36 PM
include/llvm/Analysis/LoopAccessAnalysis.h
138

Forward, but if vectorized, is likely ... (add commas)

143

Backward, but the distance allows a vectorization factor... (add comma and a)

146

Same, but ...

257

Do you really feel that, most of time time, this holds only 1 entry? Given that Dependence is only three integers, I'd recommend something larger (4, 8, 16)?

lib/Analysis/LoopAccessAnalysis.cpp
53

Please make this a command-line parameter.

801

I could be mis-remembering how this loop works, but it seems like we're doing twice as much work here as necessary. If there is a forward dependency between A and B, then there's a backward dependence between B and A? If the dependence of A and B is unknown, then the dependence of B and A is unknown. Could we take advantage of that here?

anemet added inline comments.Mar 8 2015, 7:18 PM
include/llvm/Analysis/LoopAccessAnalysis.h
257

No you're right, I don't know why I picked 1. Thanks for noticing.

lib/Analysis/LoopAccessAnalysis.cpp
53

Sure thing.

801

I don't think that is how this this code works.

*AI and *OI are accesses using the same underlying pointers. We do make sure we visit each pair only once (OI started from std::next(AI).

Now that said, you're right that if we have *multiple* instructions using either of the accesses *AI or *OI we invoke isDependent multiple times and will get the exact same result -- inDependent only uses the indices (*I1 and *I2) for debug output. So all this can probably be simplified into isDepedent only taking *AI and *OI.

I can attempt to make this simplification in a follow-up. Do you agree?

hfinkel added inline comments.Mar 9 2015, 1:12 PM
lib/Analysis/LoopAccessAnalysis.cpp
801

I can attempt to make this simplification in a follow-up. Do you agree?

Agreed. Thanks!

anemet updated this revision to Diff 21510.Mar 9 2015, 2:07 PM

Addresses Hal's comments:

  • Spelling fixes
  • Fix a SmallVector inline length
  • Command-line argument for MaxInterestingDependence
hfinkel accepted this revision.Mar 9 2015, 2:21 PM
hfinkel edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Mar 9 2015, 2:21 PM
anemet closed this revision.Mar 10 2015, 10:46 AM

r231806