[PATCH] D75628: [DA] [SCEV] Provide facility to check for total ordering based on dominance

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 5 14:17:15 PST 2020


Meinersbur added inline comments.


================
Comment at: llvm/include/llvm/Analysis/ScalarEvolution.h:1106
+  /// applied to that set of loops found. Returns false otherwise.
+  bool satisfiesTotalOrder(SmallVectorImpl<const SCEV *> &Exprs) const;
+
----------------
Since `satisfiesTotalOrder` does not add Exprs, `(Mutable)ArrayRef` might be sufficient as arguments.


================
Comment at: llvm/lib/Analysis/DependenceAnalysis.cpp:2566
   bool Disproved = false;
   if (testBounds(Dependence::DVEntry::ALL, 0, Bound, Delta)) {
     // Explore the direction vector hierarchy.
----------------
bmahjour wrote:
> Meinersbur wrote:
> > Is it even correct to call `testBounds` with SCEVExprs bounds with disjoint loop nests? Maybe the bug is in to consider `MaxLevels` instead of `CommonLevels`.
> The Banerjee Inequality requires that delta between the coefficients of the first terms of the Diophantine function `h` be in between LB and UB, where LB and UB are defined to be the sum of min/max quantities over **all** loop levels (not just the common levels), so the code is correct in looping over all loops including the siblings. This is more of a limitation in SCEV not being able to represent the bounds when they are non-invariant recurrences that straddle non-dominating loops.
> 
> I'm actually not quite sure why there is this assumption in SCEV about dominance. Do you know?
> I'm actually not quite sure why there is this assumption in SCEV about dominance. Do you know?

AFAIU it is not about dominance, but that SCEVAddRecExpr only being valid within the loop (in the loop applies dominance by the loop header). If outside the loop, `getSCEVAtScope` 'removes' the SCEVAddRecExprs for loops it is not in. Using SCEVAddRecExprs from sibling loops in the same expression would be a contradiction as it cannot be valid in both loops at the same time.

I don't know how `DependenceInfo` is supposed to work comparing instructions in sibling loops, but I'd suspect the problem being there, not in SCEV. Maybe looking up
```
// Use Banerjee's Inequalities to test an MIV subscript pair.
// (Wolfe, in the race-car book, calls this the Extreme Value Test.)
// Generally follows the discussion in Section 2.5.2 of
//
//    Optimizing Supercompilers for Supercomputers
//    Michael Wolfe
//
```
could help.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75628/new/

https://reviews.llvm.org/D75628





More information about the llvm-commits mailing list