@@ -268,10 +268,11 @@ bool Dependence::isScalar(unsigned level) const {
268
268
// ===----------------------------------------------------------------------===//
269
269
// FullDependence methods
270
270
271
- FullDependence::FullDependence (Instruction *Source, Instruction *Destination,
272
- bool PossiblyLoopIndependent,
273
- unsigned CommonLevels)
274
- : Dependence(Source, Destination), Levels(CommonLevels),
271
+ FullDependence::FullDependence (
272
+ Instruction *Source, Instruction *Destination, ScalarEvolution *SE,
273
+ const SmallVectorImpl<const SCEVPredicate *> &Assumes,
274
+ bool PossiblyLoopIndependent, unsigned CommonLevels)
275
+ : Dependence(Source, Destination, SE, Assumes), Levels(CommonLevels),
275
276
LoopIndependent(PossiblyLoopIndependent) {
276
277
Consistent = true ;
277
278
if (CommonLevels)
@@ -711,6 +712,12 @@ void Dependence::dump(raw_ostream &OS) const {
711
712
OS << " splitable" ;
712
713
}
713
714
OS << " !\n " ;
715
+
716
+ SCEVUnionPredicate Assumptions = getRuntimeAssumptions ();
717
+ if (!Assumptions.isAlwaysTrue ()) {
718
+ OS << " Runtime Assumptions:\n " ;
719
+ Assumptions.print (OS, 2 );
720
+ }
714
721
}
715
722
716
723
// Returns NoAlias/MayAliass/MustAlias for two memory locations based upon their
@@ -3574,7 +3581,11 @@ bool DependenceInfo::invalidate(Function &F, const PreservedAnalyses &PA,
3574
3581
Inv.invalidate <LoopAnalysis>(F, PA);
3575
3582
}
3576
3583
3577
- SCEVUnionPredicate DependenceInfo::getRuntimeAssumptions () {
3584
+ SCEVUnionPredicate DependenceInfo::getRuntimeAssumptions () const {
3585
+ return SCEVUnionPredicate (Assumptions, *SE);
3586
+ }
3587
+
3588
+ SCEVUnionPredicate Dependence::getRuntimeAssumptions () const {
3578
3589
return SCEVUnionPredicate (Assumptions, *SE);
3579
3590
}
3580
3591
@@ -3590,7 +3601,9 @@ SCEVUnionPredicate DependenceInfo::getRuntimeAssumptions() {
3590
3601
// Care is required to keep the routine below, getSplitIteration(),
3591
3602
// up to date with respect to this routine.
3592
3603
std::unique_ptr<Dependence>
3593
- DependenceInfo::depends (Instruction *Src, Instruction *Dst) {
3604
+ DependenceInfo::depends (Instruction *Src, Instruction *Dst,
3605
+ bool UnderRuntimeAssumptions) {
3606
+ SmallVector<const SCEVPredicate *, 4 > Assume;
3594
3607
bool PossiblyLoopIndependent = true ;
3595
3608
if (Src == Dst)
3596
3609
PossiblyLoopIndependent = false ;
@@ -3602,7 +3615,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst) {
3602
3615
if (!isLoadOrStore (Src) || !isLoadOrStore (Dst)) {
3603
3616
// can only analyze simple loads and stores, i.e., no calls, invokes, etc.
3604
3617
LLVM_DEBUG (dbgs () << " can only handle simple loads and stores\n " );
3605
- return std::make_unique<Dependence>(Src, Dst);
3618
+ return std::make_unique<Dependence>(Src, Dst, SE, Assume );
3606
3619
}
3607
3620
3608
3621
const MemoryLocation &DstLoc = MemoryLocation::get (Dst);
@@ -3613,7 +3626,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst) {
3613
3626
case AliasResult::PartialAlias:
3614
3627
// cannot analyse objects if we don't understand their aliasing.
3615
3628
LLVM_DEBUG (dbgs () << " can't analyze may or partial alias\n " );
3616
- return std::make_unique<Dependence>(Src, Dst);
3629
+ return std::make_unique<Dependence>(Src, Dst, SE, Assume );
3617
3630
case AliasResult::NoAlias:
3618
3631
// If the objects noalias, they are distinct, accesses are independent.
3619
3632
LLVM_DEBUG (dbgs () << " no alias\n " );
@@ -3626,7 +3639,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst) {
3626
3639
// The dependence test gets confused if the size of the memory accesses
3627
3640
// differ.
3628
3641
LLVM_DEBUG (dbgs () << " can't analyze must alias with different sizes\n " );
3629
- return std::make_unique<Dependence>(Src, Dst);
3642
+ return std::make_unique<Dependence>(Src, Dst, SE, Assume );
3630
3643
}
3631
3644
3632
3645
Value *SrcPtr = getLoadStorePointerOperand (Src);
@@ -3645,7 +3658,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst) {
3645
3658
// We check this upfront so we don't crash in cases where getMinusSCEV()
3646
3659
// returns a SCEVCouldNotCompute.
3647
3660
LLVM_DEBUG (dbgs () << " can't analyze SCEV with different pointer base\n " );
3648
- return std::make_unique<Dependence>(Src, Dst);
3661
+ return std::make_unique<Dependence>(Src, Dst, SE, Assume );
3649
3662
}
3650
3663
3651
3664
uint64_t EltSize = SrcLoc.Size .toRaw ();
@@ -3656,18 +3669,28 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst) {
3656
3669
3657
3670
if (Src != Dst) {
3658
3671
// Check that memory access offsets are multiples of element sizes.
3659
- if (!SE->isKnownMultipleOf (SrcEv, EltSize, Assumptions ) ||
3660
- !SE->isKnownMultipleOf (DstEv, EltSize, Assumptions )) {
3672
+ if (!SE->isKnownMultipleOf (SrcEv, EltSize, Assume ) ||
3673
+ !SE->isKnownMultipleOf (DstEv, EltSize, Assume )) {
3661
3674
LLVM_DEBUG (dbgs () << " can't analyze SCEV with different offsets\n " );
3662
- return std::make_unique<Dependence>(Src, Dst);
3675
+ return std::make_unique<Dependence>(Src, Dst, SE, Assume );
3663
3676
}
3664
3677
}
3665
3678
3679
+ if (Assumptions.empty ())
3680
+ Assumptions.append (Assume.begin (), Assume.end ());
3681
+ else
3682
+ // Add non-redundant assumptions.
3683
+ for (auto *P : Assume)
3684
+ for (auto *A : Assumptions)
3685
+ if (!A->implies (P, *SE))
3686
+ Assumptions.push_back (P);
3687
+
3666
3688
establishNestingLevels (Src, Dst);
3667
3689
LLVM_DEBUG (dbgs () << " common nesting levels = " << CommonLevels << " \n " );
3668
3690
LLVM_DEBUG (dbgs () << " maximum nesting levels = " << MaxLevels << " \n " );
3669
3691
3670
- FullDependence Result (Src, Dst, PossiblyLoopIndependent, CommonLevels);
3692
+ FullDependence Result (Src, Dst, SE, Assume, PossiblyLoopIndependent,
3693
+ CommonLevels);
3671
3694
++TotalArrayPairs;
3672
3695
3673
3696
unsigned Pairs = 1 ;
@@ -4065,7 +4088,7 @@ const SCEV *DependenceInfo::getSplitIteration(const Dependence &Dep,
4065
4088
// establish loop nesting levels
4066
4089
establishNestingLevels (Src, Dst);
4067
4090
4068
- FullDependence Result (Src, Dst, false , CommonLevels);
4091
+ FullDependence Result (Src, Dst, SE, Dep. Assumptions , false , CommonLevels);
4069
4092
4070
4093
unsigned Pairs = 1 ;
4071
4094
SmallVector<Subscript, 2 > Pair (Pairs);
0 commit comments