This is an archive of the discontinued LLVM Phabricator instance.

Fix how DependenceAnalysis calls de-linearization
ClosedPublic

Authored by vaivaswatha on Aug 5 2015, 10:36 AM.

Details

Summary

DependenceAnalysis currently does not call de-linearization correctly. Fix it based on how de-linearization is called in Delinearization.cpp.

Diff Detail

Repository
rL LLVM

Event Timeline

vaivaswatha retitled this revision from to Fix how DependenceAnalysis calls de-linearization.
vaivaswatha updated this object.
vaivaswatha added reviewers: jingyue, sebpop, spop.
vaivaswatha set the repository for this revision to rL LLVM.
vaivaswatha added a subscriber: llvm-commits.
vaivaswatha updated this revision to Diff 31426.Aug 5 2015, 8:44 PM

Added changes in DependenceAnalysis.h

jingyue resigned from this revision.Aug 11 2015, 8:46 PM
jingyue removed a reviewer: jingyue.

I don't have enough expertise on DependenceAnalysis unfortunately. You'd have to wait for others to chime it.

hfinkel added inline comments.
lib/Analysis/DependenceAnalysis.cpp
3247–3262

Can these be const Instruction*?

3255

The code in Delinearization.cpp does this:

// Delinearize the memory access as analyzed in all the surrounding loops.
// Do not analyze memory accesses outside loops.
for (Loop *L = LI->getLoopFor(BB); L != nullptr; L = L->getParentLoop()) {
  const SCEV *AccessFn = SE->getSCEVAtScope(getPointerOperand(*Inst), L);

So it walks up the chain of loops instead of just always using the inner loop. Should something similar be done here?

3429

Am I correct that an alternative way to fix this problem is to call getSCEVAtScope on the SCEVs being passed here?

vaivaswatha added inline comments.Aug 12 2015, 4:21 AM
lib/Analysis/DependenceAnalysis.cpp
3247–3262

Ideally, yes. However, ScalarEvolution::getElementSize() below does not take a const Instruction as its argument.

3255

From what I understand, It doesn't make much sense to do this here since all we need is to see the value's evolution in the innermost loop its defined in.

3429

Yes. Note that getSCEVAtScope needs to be called on "Src" and not "Pair[0].Src".
Also, I've removed the check "Pairs == 1" because its too strict. Even when the indices are linearized, its possible that the first index is 0 and the second one actually contains the linearized index (this is quite a common case) when indexing arrays (rather than pointers).

The assert on Src element size and Dst element size was incorrect. Fixing that.

hfinkel accepted this revision.Aug 16 2015, 2:38 AM
hfinkel added a reviewer: hfinkel.

LGTM.

This revision is now accepted and ready to land.Aug 16 2015, 2:38 AM

@hfinkel Thank you very much for the review. I don't have permission to commit to the repo. Can you please commit this on my behalf?

hfinkel closed this revision.Aug 18 2015, 7:57 PM

r245408, thanks!