@@ -97,10 +97,11 @@ namespace llvm {
97
97
bool PeelFirst : 1 ; // Peeling the first iteration will break dependence.
98
98
bool PeelLast : 1 ; // Peeling the last iteration will break the dependence.
99
99
bool Splitable : 1 ; // Splitting the loop will break dependence.
100
+ bool SeparateLoops : 1 ; // Is performed across two separate loop nests.
100
101
const SCEV *Distance = nullptr ; // NULL implies no distance available.
101
102
DVEntry ()
102
103
: Direction(ALL), Scalar(true ), PeelFirst(false ), PeelLast(false ),
103
- Splitable (false ) {}
104
+ Splitable (false ), SeparateLoops( false ) {}
104
105
};
105
106
106
107
// / getSrc - Returns the source instruction for this dependence.
@@ -182,6 +183,10 @@ namespace llvm {
182
183
// / the dependence.
183
184
virtual bool isSplitable (unsigned Level) const { return false ; }
184
185
186
+ // / inSeparateLoops - Returns true if this level is performed across
187
+ // / two separate loop nests.
188
+ virtual bool inSeparateLoops (unsigned Level) const { return false ; }
189
+
185
190
// / isScalar - Returns true if a particular level is scalar; that is,
186
191
// / if no subscript in the source or destination mention the induction
187
192
// / variable associated with the loop at this level.
@@ -275,6 +280,10 @@ namespace llvm {
275
280
// / the dependence.
276
281
bool isSplitable (unsigned Level) const override ;
277
282
283
+ // / inSeparateLoops - Returns true if this level is performed across
284
+ // / two separate loop nests.
285
+ bool inSeparateLoops (unsigned Level) const override ;
286
+
278
287
// / isScalar - Returns true if a particular level is scalar; that is,
279
288
// / if no subscript in the source or destination mention the induction
280
289
// / variable associated with the loop at this level.
@@ -405,7 +414,8 @@ namespace llvm {
405
414
const SCEV *A;
406
415
const SCEV *B;
407
416
const SCEV *C;
408
- const Loop *AssociatedLoop;
417
+ const Loop *AssociatedSrcLoop;
418
+ const Loop *AssociatedDstLoop;
409
419
410
420
public:
411
421
// / isEmpty - Return true if the constraint is of kind Empty.
@@ -449,18 +459,25 @@ namespace llvm {
449
459
// / Otherwise assert.
450
460
const SCEV *getD () const ;
451
461
452
- // / getAssociatedLoop - Returns the loop associated with this constraint.
453
- const Loop *getAssociatedLoop () const ;
462
+ // / getAssociatedSrcLoop - Returns the source loop associated with this
463
+ // / constraint.
464
+ const Loop *getAssociatedSrcLoop () const ;
465
+
466
+ // / getAssociatedDstLoop - Returns the destination loop associated with
467
+ // / this constraint.
468
+ const Loop *getAssociatedDstLoop () const ;
454
469
455
470
// / setPoint - Change a constraint to Point.
456
- void setPoint (const SCEV *X, const SCEV *Y, const Loop *CurrentLoop);
471
+ void setPoint (const SCEV *X, const SCEV *Y, const Loop *CurrentSrcLoop,
472
+ const Loop *CurrentDstLoop);
457
473
458
474
// / setLine - Change a constraint to Line.
459
- void setLine (const SCEV *A, const SCEV *B,
460
- const SCEV *C , const Loop *CurrentLoop );
475
+ void setLine (const SCEV *A, const SCEV *B, const SCEV *C,
476
+ const Loop *CurrentSrcLoop , const Loop *CurrentDstLoop );
461
477
462
478
// / setDistance - Change a constraint to Distance.
463
- void setDistance (const SCEV *D, const Loop *CurrentLoop);
479
+ void setDistance (const SCEV *D, const Loop *CurrentSrcLoop,
480
+ const Loop *CurrentDstLoop);
464
481
465
482
// / setEmpty - Change a constraint to Empty.
466
483
void setEmpty ();
@@ -473,6 +490,10 @@ namespace llvm {
473
490
void dump (raw_ostream &OS) const ;
474
491
};
475
492
493
+ // / Returns true if two loops are the same or they have the same upperbound
494
+ // / and depth
495
+ bool areLoopsSimilar (const Loop *SrcLoop, const Loop *DstLoop) const ;
496
+
476
497
// / establishNestingLevels - Examines the loop nesting of the Src and Dst
477
498
// / instructions and establishes their shared loops. Sets the variables
478
499
// / CommonLevels, SrcLevels, and MaxLevels.
@@ -484,8 +505,8 @@ namespace llvm {
484
505
// / This lets us allocate vectors MaxLevels in length, with room for every
485
506
// / distinct loop referenced in both the source and destination subscripts.
486
507
// / The variable SrcLevels is the nesting depth of the source instruction.
487
- // / It's used to help calculate distinct loops referenced by the destination.
488
- // / Here's the map from loops to levels:
508
+ // / It's used to help calculate distinct loops referenced by the
509
+ // / destination. Here's the map from loops to levels:
489
510
// / 0 - unused
490
511
// / 1 - outermost common loop
491
512
// / ... - other common loops
@@ -523,10 +544,22 @@ namespace llvm {
523
544
// / e - 5
524
545
// / f - 6
525
546
// / g - 7 = MaxLevels
526
- void establishNestingLevels (const Instruction *Src,
527
- const Instruction *Dst);
528
-
529
- unsigned CommonLevels, SrcLevels, MaxLevels;
547
+ // / If ConsiderSeparateLoops is true then we also want to consider similar
548
+ // / seperate loops. Assume that loop nests at level c and e are similar,
549
+ // / meaning that they have the same upperbound and depth. Then we consider
550
+ // / them as a common level.
551
+ // / a - 1
552
+ // / b - 2
553
+ // / <c, e> - 3 = CommonLevels
554
+ // / d - 4 = SrcLevels
555
+ // / f - 5
556
+ // / g - 6 = MaxLevels
557
+ // / SeparateLevels means that how many of the last common levels are
558
+ // / separated, which is 1 in this case.
559
+ void establishNestingLevels (const Instruction *Src, const Instruction *Dst,
560
+ bool ConsiderSeparateLoops = false );
561
+
562
+ unsigned CommonLevels, SrcLevels, MaxLevels, SeparateLevels;
530
563
531
564
// / mapSrcLoop - Given one of the loops containing the source, return
532
565
// / its level index in our numbering scheme.
@@ -665,13 +698,10 @@ namespace llvm {
665
698
// / Returns true if any possible dependence is disproved.
666
699
// / If there might be a dependence, returns false.
667
700
// / Sets appropriate direction and distance.
668
- bool strongSIVtest (const SCEV *Coeff,
669
- const SCEV *SrcConst,
670
- const SCEV *DstConst,
671
- const Loop *CurrentLoop,
672
- unsigned Level,
673
- FullDependence &Result,
674
- Constraint &NewConstraint) const ;
701
+ bool strongSIVtest (const SCEV *Coeff, const SCEV *SrcConst,
702
+ const SCEV *DstConst, const Loop *CurrentSrcLoop,
703
+ const Loop *CurrentDstLoop, unsigned Level,
704
+ FullDependence &Result, Constraint &NewConstraint) const ;
675
705
676
706
// / weakCrossingSIVtest - Tests the weak-crossing SIV subscript pair
677
707
// / (Src and Dst) for dependence.
@@ -683,13 +713,10 @@ namespace llvm {
683
713
// / Sets appropriate direction entry.
684
714
// / Set consistent to false.
685
715
// / Marks the dependence as splitable.
686
- bool weakCrossingSIVtest (const SCEV *SrcCoeff,
687
- const SCEV *SrcConst,
688
- const SCEV *DstConst,
689
- const Loop *CurrentLoop,
690
- unsigned Level,
691
- FullDependence &Result,
692
- Constraint &NewConstraint,
716
+ bool weakCrossingSIVtest (const SCEV *SrcCoeff, const SCEV *SrcConst,
717
+ const SCEV *DstConst, const Loop *CurrentSrcLoop,
718
+ const Loop *CurrentDstLoop, unsigned Level,
719
+ FullDependence &Result, Constraint &NewConstraint,
693
720
const SCEV *&SplitIter) const ;
694
721
695
722
// / ExactSIVtest - Tests the SIV subscript pair
@@ -701,13 +728,10 @@ namespace llvm {
701
728
// / If there might be a dependence, returns false.
702
729
// / Sets appropriate direction entry.
703
730
// / Set consistent to false.
704
- bool exactSIVtest (const SCEV *SrcCoeff,
705
- const SCEV *DstCoeff,
706
- const SCEV *SrcConst,
707
- const SCEV *DstConst,
708
- const Loop *CurrentLoop,
709
- unsigned Level,
710
- FullDependence &Result,
731
+ bool exactSIVtest (const SCEV *SrcCoeff, const SCEV *DstCoeff,
732
+ const SCEV *SrcConst, const SCEV *DstConst,
733
+ const Loop *CurrentSrcLoop, const Loop *CurrentDstLoop,
734
+ unsigned Level, FullDependence &Result,
711
735
Constraint &NewConstraint) const ;
712
736
713
737
// / weakZeroSrcSIVtest - Tests the weak-zero SIV subscript pair
@@ -720,11 +744,9 @@ namespace llvm {
720
744
// / Sets appropriate direction entry.
721
745
// / Set consistent to false.
722
746
// / If loop peeling will break the dependence, mark appropriately.
723
- bool weakZeroSrcSIVtest (const SCEV *DstCoeff,
724
- const SCEV *SrcConst,
725
- const SCEV *DstConst,
726
- const Loop *CurrentLoop,
727
- unsigned Level,
747
+ bool weakZeroSrcSIVtest (const SCEV *DstCoeff, const SCEV *SrcConst,
748
+ const SCEV *DstConst, const Loop *CurrentSrcLoop,
749
+ const Loop *CurrentDstLoop, unsigned Level,
728
750
FullDependence &Result,
729
751
Constraint &NewConstraint) const ;
730
752
@@ -738,11 +760,9 @@ namespace llvm {
738
760
// / Sets appropriate direction entry.
739
761
// / Set consistent to false.
740
762
// / If loop peeling will break the dependence, mark appropriately.
741
- bool weakZeroDstSIVtest (const SCEV *SrcCoeff,
742
- const SCEV *SrcConst,
743
- const SCEV *DstConst,
744
- const Loop *CurrentLoop,
745
- unsigned Level,
763
+ bool weakZeroDstSIVtest (const SCEV *SrcCoeff, const SCEV *SrcConst,
764
+ const SCEV *DstConst, const Loop *CurrentSrcLoop,
765
+ const Loop *CurrentDstLoop, unsigned Level,
746
766
FullDependence &Result,
747
767
Constraint &NewConstraint) const ;
748
768
0 commit comments