@@ -152,13 +152,28 @@ namespace llvm {
152
152
// / source and destination of the dependence.
153
153
virtual unsigned getLevels () const { return 0 ; }
154
154
155
+ // / getSeparateLevels - Returns the number of separate loops surrounding
156
+ // / the source and destination of the dependence.
157
+ virtual unsigned getSeparateLevels () const { return 0 ; }
158
+
159
+ // / getDVEntry - Returns the DV entry associated with a regular or a
160
+ // / separate level
161
+ DVEntry getDVEntry (unsigned Level, bool Separate) const ;
162
+
155
163
// / getDirection - Returns the direction associated with a particular
156
- // / level.
157
- virtual unsigned getDirection (unsigned Level) const { return DVEntry::ALL; }
164
+ // / level. If Separate is set to true, information about a separate
165
+ // / level is provided.
166
+ virtual unsigned getDirection (unsigned Level, bool Separate = false ) const {
167
+ return DVEntry::ALL;
168
+ }
158
169
159
170
// / getDistance - Returns the distance (or NULL) associated with a
160
- // / particular level.
161
- virtual const SCEV *getDistance (unsigned Level) const { return nullptr ; }
171
+ // / particular level. If Separate is set to true, information about
172
+ // / a separate level is provided.
173
+ virtual const SCEV *getDistance (unsigned Level,
174
+ bool Separate = false ) const {
175
+ return nullptr ;
176
+ }
162
177
163
178
// / Check if the direction vector is negative. A negative direction
164
179
// / vector means Src and Dst are reversed in the actual program.
@@ -171,21 +186,35 @@ namespace llvm {
171
186
virtual bool normalize (ScalarEvolution *SE) { return false ; }
172
187
173
188
// / isPeelFirst - Returns true if peeling the first iteration from
174
- // / this loop will break this dependence.
175
- virtual bool isPeelFirst (unsigned Level) const { return false ; }
189
+ // / this loop will break this dependence. If Separate is set to true,
190
+ // / information about a separate level is provided.
191
+ virtual bool isPeelFirst (unsigned Level, bool Separate = false ) const {
192
+ return false ;
193
+ }
176
194
177
195
// / isPeelLast - Returns true if peeling the last iteration from
178
- // / this loop will break this dependence.
179
- virtual bool isPeelLast (unsigned Level) const { return false ; }
196
+ // / this loop will break this dependence. If Separate is set to true,
197
+ // / information about a separate level is provided.
198
+ virtual bool isPeelLast (unsigned Level, bool Separate = false ) const {
199
+ return false ;
200
+ }
180
201
181
202
// / isSplitable - Returns true if splitting this loop will break
182
- // / the dependence.
183
- virtual bool isSplitable (unsigned Level) const { return false ; }
203
+ // / the dependence. If Separate is set to true, information about a
204
+ // / separate level is provided.
205
+ virtual bool isSplitable (unsigned Level, bool Separate = false ) const {
206
+ return false ;
207
+ }
208
+
209
+ // / inSeparateLoops - Returns true if this level is performed across
210
+ // / two separate loop nests.
211
+ virtual bool inSeparateLoops (unsigned Level) const { return false ; }
184
212
185
213
// / isScalar - Returns true if a particular level is scalar; that is,
186
214
// / if no subscript in the source or destination mention the induction
187
- // / variable associated with the loop at this level.
188
- virtual bool isScalar (unsigned Level) const ;
215
+ // / variable associated with the loop at this level. If Separate is
216
+ // / set to true, information about a separate level is provided.
217
+ virtual bool isScalar (unsigned Level, bool Separate = false ) const ;
189
218
190
219
// / getNextPredecessor - Returns the value of the NextPredecessor
191
220
// / field.
@@ -245,13 +274,33 @@ namespace llvm {
245
274
// / source and destination of the dependence.
246
275
unsigned getLevels () const override { return Levels; }
247
276
277
+ // / getSeparateLevels - Returns the number of separate loops surrounding
278
+ // / the source and destination of the dependence.
279
+ unsigned getSeparateLevels () const override { return SeparateLevels; }
280
+
281
+ // / getDVEntry - Returns the DV entry associated with a regular or a
282
+ // / separate level
283
+ DVEntry getDVEntry (unsigned Level, bool Separate) const {
284
+ if (!Separate) {
285
+ assert (0 < Level && Level <= Levels && " Level out of range" );
286
+ return DV[Level - 1 ];
287
+ } else {
288
+ assert (Levels < Level && Level <= Levels + SeparateLevels &&
289
+ " Separate level out of range" );
290
+ return DVSeparate[Level - Levels - 1 ];
291
+ }
292
+ }
293
+
248
294
// / getDirection - Returns the direction associated with a particular
249
- // / level.
250
- unsigned getDirection (unsigned Level) const override ;
295
+ // / level. If Separate is set to true, information about a separate
296
+ // / level is provided.
297
+ unsigned getDirection (unsigned Level, bool Separate = false ) const override ;
251
298
252
299
// / getDistance - Returns the distance (or NULL) associated with a
253
- // / particular level.
254
- const SCEV *getDistance (unsigned Level) const override ;
300
+ // / particular level. If Separate is set to true, information about
301
+ // / a separate level is provided.
302
+ const SCEV *getDistance (unsigned Level,
303
+ bool Separate = false ) const override ;
255
304
256
305
// / Check if the direction vector is negative. A negative direction
257
306
// / vector means Src and Dst are reversed in the actual program.
@@ -264,27 +313,37 @@ namespace llvm {
264
313
bool normalize (ScalarEvolution *SE) override ;
265
314
266
315
// / isPeelFirst - Returns true if peeling the first iteration from
267
- // / this loop will break this dependence.
268
- bool isPeelFirst (unsigned Level) const override ;
316
+ // / this loop will break this dependence. If Separate is set to true,
317
+ // / information about a separate level is provided.
318
+ bool isPeelFirst (unsigned Level, bool Separate = false ) const override ;
269
319
270
320
// / isPeelLast - Returns true if peeling the last iteration from
271
- // / this loop will break this dependence.
272
- bool isPeelLast (unsigned Level) const override ;
321
+ // / this loop will break this dependence. If Separate is set to true,
322
+ // / information about a separate level is provided.
323
+ bool isPeelLast (unsigned Level, bool Separate = false ) const override ;
273
324
274
325
// / isSplitable - Returns true if splitting the loop will break
275
- // / the dependence.
276
- bool isSplitable (unsigned Level) const override ;
326
+ // / the dependence. If Separate is set to true, information about a
327
+ // / separate level is provided.
328
+ bool isSplitable (unsigned Level, bool Separate = false ) const override ;
329
+
330
+ // / inSeparateLoops - Returns true if this level is performed across
331
+ // / two separate loop nests.
332
+ bool inSeparateLoops (unsigned Level) const override ;
277
333
278
334
// / isScalar - Returns true if a particular level is scalar; that is,
279
335
// / if no subscript in the source or destination mention the induction
280
- // / variable associated with the loop at this level.
281
- bool isScalar (unsigned Level) const override ;
336
+ // / variable associated with the loop at this level. If Separate is
337
+ // / set to true, information about a separate level is provided.
338
+ bool isScalar (unsigned Level, bool Separate = false ) const override ;
282
339
283
340
private:
284
341
unsigned short Levels;
342
+ unsigned short SeparateLevels;
285
343
bool LoopIndependent;
286
344
bool Consistent; // Init to true, then refine.
287
345
std::unique_ptr<DVEntry[]> DV;
346
+ std::unique_ptr<DVEntry[]> DVSeparate;
288
347
friend class DependenceInfo ;
289
348
};
290
349
@@ -405,7 +464,8 @@ namespace llvm {
405
464
const SCEV *A;
406
465
const SCEV *B;
407
466
const SCEV *C;
408
- const Loop *AssociatedLoop;
467
+ const Loop *AssociatedSrcLoop;
468
+ const Loop *AssociatedDstLoop;
409
469
410
470
public:
411
471
// / isEmpty - Return true if the constraint is of kind Empty.
@@ -449,18 +509,25 @@ namespace llvm {
449
509
// / Otherwise assert.
450
510
const SCEV *getD () const ;
451
511
452
- // / getAssociatedLoop - Returns the loop associated with this constraint.
453
- const Loop *getAssociatedLoop () const ;
512
+ // / getAssociatedSrcLoop - Returns the source loop associated with this
513
+ // / constraint.
514
+ const Loop *getAssociatedSrcLoop () const ;
515
+
516
+ // / getAssociatedDstLoop - Returns the destination loop associated with
517
+ // / this constraint.
518
+ const Loop *getAssociatedDstLoop () const ;
454
519
455
520
// / setPoint - Change a constraint to Point.
456
- void setPoint (const SCEV *X, const SCEV *Y, const Loop *CurrentLoop);
521
+ void setPoint (const SCEV *X, const SCEV *Y, const Loop *CurrentSrcLoop,
522
+ const Loop *CurrentDstLoop);
457
523
458
524
// / setLine - Change a constraint to Line.
459
- void setLine (const SCEV *A, const SCEV *B,
460
- const SCEV *C , const Loop *CurrentLoop );
525
+ void setLine (const SCEV *A, const SCEV *B, const SCEV *C,
526
+ const Loop *CurrentSrcLoop , const Loop *CurrentDstLoop );
461
527
462
528
// / setDistance - Change a constraint to Distance.
463
- void setDistance (const SCEV *D, const Loop *CurrentLoop);
529
+ void setDistance (const SCEV *D, const Loop *CurrentSrcLoop,
530
+ const Loop *CurrentDstLoop);
464
531
465
532
// / setEmpty - Change a constraint to Empty.
466
533
void setEmpty ();
@@ -473,6 +540,10 @@ namespace llvm {
473
540
void dump (raw_ostream &OS) const ;
474
541
};
475
542
543
+ // / Returns true if two loops are the same or they have the same tripcount
544
+ // / and depth
545
+ bool areLoopsSimilar (const Loop *SrcLoop, const Loop *DstLoop) const ;
546
+
476
547
// / establishNestingLevels - Examines the loop nesting of the Src and Dst
477
548
// / instructions and establishes their shared loops. Sets the variables
478
549
// / CommonLevels, SrcLevels, and MaxLevels.
@@ -523,10 +594,15 @@ namespace llvm {
523
594
// / e - 5
524
595
// / f - 6
525
596
// / g - 7 = MaxLevels
526
- void establishNestingLevels (const Instruction *Src,
527
- const Instruction *Dst);
597
+ // / SeparateLevels counts the number of loop levels after the common levels
598
+ // / that are not identical but are considered similar. Two levels are
599
+ // / considered similar if they have the same trip count and the same
600
+ // / nesting depth.
601
+ // / For example, if loops `c` and `e` are similar, then they contribute to
602
+ // / the SeparateLevels count and SeparateLevels is set to 1.
603
+ void establishNestingLevels (const Instruction *Src, const Instruction *Dst);
528
604
529
- unsigned CommonLevels, SrcLevels, MaxLevels;
605
+ unsigned CommonLevels, SrcLevels, MaxLevels, SeparateLevels ;
530
606
531
607
// / mapSrcLoop - Given one of the loops containing the source, return
532
608
// / its level index in our numbering scheme.
@@ -668,7 +744,8 @@ namespace llvm {
668
744
bool strongSIVtest (const SCEV *Coeff,
669
745
const SCEV *SrcConst,
670
746
const SCEV *DstConst,
671
- const Loop *CurrentLoop,
747
+ const Loop *CurrentSrcLoop,
748
+ const Loop *CurrentDstLoop,
672
749
unsigned Level,
673
750
FullDependence &Result,
674
751
Constraint &NewConstraint) const ;
@@ -686,7 +763,8 @@ namespace llvm {
686
763
bool weakCrossingSIVtest (const SCEV *SrcCoeff,
687
764
const SCEV *SrcConst,
688
765
const SCEV *DstConst,
689
- const Loop *CurrentLoop,
766
+ const Loop *CurrentSrcLoop,
767
+ const Loop *CurrentDstLoop,
690
768
unsigned Level,
691
769
FullDependence &Result,
692
770
Constraint &NewConstraint,
@@ -705,7 +783,8 @@ namespace llvm {
705
783
const SCEV *DstCoeff,
706
784
const SCEV *SrcConst,
707
785
const SCEV *DstConst,
708
- const Loop *CurrentLoop,
786
+ const Loop *CurrentSrcLoop,
787
+ const Loop *CurrentDstLoop,
709
788
unsigned Level,
710
789
FullDependence &Result,
711
790
Constraint &NewConstraint) const ;
@@ -723,7 +802,8 @@ namespace llvm {
723
802
bool weakZeroSrcSIVtest (const SCEV *DstCoeff,
724
803
const SCEV *SrcConst,
725
804
const SCEV *DstConst,
726
- const Loop *CurrentLoop,
805
+ const Loop *CurrentSrcLoop,
806
+ const Loop *CurrentDstLoop,
727
807
unsigned Level,
728
808
FullDependence &Result,
729
809
Constraint &NewConstraint) const ;
@@ -741,7 +821,8 @@ namespace llvm {
741
821
bool weakZeroDstSIVtest (const SCEV *SrcCoeff,
742
822
const SCEV *SrcConst,
743
823
const SCEV *DstConst,
744
- const Loop *CurrentLoop,
824
+ const Loop *CurrentSrcLoop,
825
+ const Loop *CurrentDstLoop,
745
826
unsigned Level,
746
827
FullDependence &Result,
747
828
Constraint &NewConstraint) const ;
0 commit comments