@@ -14564,11 +14564,11 @@ bool SemaOpenMP::analyzeLoopSequence(Stmt *LoopSeqStmt,
14564
14564
auto StoreLoopStatements = [](LoopAnalysis &Analysis, Stmt *LoopStmt) {
14565
14565
if (auto *For = dyn_cast<ForStmt>(LoopStmt)) {
14566
14566
Analysis.OriginalInits.push_back(For->getInit());
14567
- Analysis.ForStmt = For;
14567
+ Analysis.TheForStmt = For;
14568
14568
} else {
14569
14569
auto *CXXFor = cast<CXXForRangeStmt>(LoopStmt);
14570
14570
Analysis.OriginalInits.push_back(CXXFor->getBeginStmt());
14571
- Analysis.ForStmt = CXXFor;
14571
+ Analysis.TheForStmt = CXXFor;
14572
14572
}
14573
14573
};
14574
14574
@@ -16019,7 +16019,9 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16019
16019
16020
16020
// SeqAnalysis.LoopSeqSize exists mostly to handle dependent contexts,
16021
16021
// otherwise it must be the same as SeqAnalysis.Loops.size().
16022
- assert(SeqAnalysis.LoopSeqSize == SeqAnalysis.Loops.size());
16022
+ assert(SeqAnalysis.LoopSeqSize == SeqAnalysis.Loops.size() &&
16023
+ "Inconsistent size of the loop sequence and the number of loops "
16024
+ "found in the sequence");
16023
16025
16024
16026
// Handle clauses, which can be any of the following: [looprange, apply]
16025
16027
const OMPLoopRangeClause *LRC =
@@ -16084,7 +16086,7 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16084
16086
// Select the type with the largest bit width among all induction variables
16085
16087
QualType IVType =
16086
16088
SeqAnalysis.Loops[FirstVal - 1].HelperExprs.IterationVarRef->getType();
16087
- for (unsigned I = FirstVal; I < LastVal; ++I ) {
16089
+ for (unsigned I : llvm::seq<unsigned>( FirstVal, LastVal) ) {
16088
16090
QualType CurrentIVType =
16089
16091
SeqAnalysis.Loops[I].HelperExprs.IterationVarRef->getType();
16090
16092
if (Context.getTypeSize(CurrentIVType) > Context.getTypeSize(IVType)) {
@@ -16146,9 +16148,7 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16146
16148
// original loop. The preinit structure must ensure that hidden variables
16147
16149
// like '.omp.fuse.max' are still properly handled.
16148
16150
// Transformations that apply this concept: Loopranged Fuse, Split
16149
- if (!SeqAnalysis.LoopSequencePreInits.empty()) {
16150
- llvm::append_range(PreInits, SeqAnalysis.LoopSequencePreInits);
16151
- }
16151
+ llvm::append_range(PreInits, SeqAnalysis.LoopSequencePreInits);
16152
16152
16153
16153
// Process each single loop to generate and collect declarations
16154
16154
// and statements for all helper expressions related to
@@ -16170,19 +16170,18 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16170
16170
for (unsigned int I = FirstVal - 1, J = 0; I < LastVal; ++I, ++J) {
16171
16171
if (SeqAnalysis.Loops[I].isRegularLoop()) {
16172
16172
addLoopPreInits(Context, SeqAnalysis.Loops[I].HelperExprs,
16173
- SeqAnalysis.Loops[I].ForStmt ,
16173
+ SeqAnalysis.Loops[I].TheForStmt ,
16174
16174
SeqAnalysis.Loops[I].OriginalInits, PreInits);
16175
16175
} else if (SeqAnalysis.Loops[I].isLoopTransformation()) {
16176
16176
// For transformed loops, insert both pre-inits and original inits.
16177
16177
// Order matters: pre-inits may define variables used in the original
16178
16178
// inits such as upper bounds...
16179
16179
SmallVector<Stmt *> &TransformPreInit =
16180
16180
SeqAnalysis.Loops[TransformIndex++].TransformsPreInits;
16181
- if (!TransformPreInit.empty())
16182
- llvm::append_range(PreInits, TransformPreInit);
16181
+ llvm::append_range(PreInits, TransformPreInit);
16183
16182
16184
16183
addLoopPreInits(Context, SeqAnalysis.Loops[I].HelperExprs,
16185
- SeqAnalysis.Loops[I].ForStmt ,
16184
+ SeqAnalysis.Loops[I].TheForStmt ,
16186
16185
SeqAnalysis.Loops[I].OriginalInits, PreInits);
16187
16186
}
16188
16187
auto [UBVD, UBDStmt] =
@@ -16270,7 +16269,7 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16270
16269
// omp.fuse.max = max(omp.temp1, omp.temp0)
16271
16270
16272
16271
ExprResult MaxExpr;
16273
- // I is the true
16272
+ // I is the range of loops in the sequence that we fuse.
16274
16273
for (unsigned I = FirstVal - 1, J = 0; I < LastVal; ++I, ++J) {
16275
16274
DeclRefExpr *NIRef = MakeVarDeclRef(NIVarDecls[J]);
16276
16275
QualType NITy = NIRef->getType();
@@ -16382,13 +16381,13 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16382
16381
16383
16382
// If the loop is a CXXForRangeStmt then the iterator variable is needed
16384
16383
if (auto *SourceCXXFor =
16385
- dyn_cast<CXXForRangeStmt>(SeqAnalysis.Loops[I].ForStmt ))
16384
+ dyn_cast<CXXForRangeStmt>(SeqAnalysis.Loops[I].TheForStmt ))
16386
16385
BodyStmts.push_back(SourceCXXFor->getLoopVarStmt());
16387
16386
16388
16387
Stmt *Body =
16389
- (isa<ForStmt>(SeqAnalysis.Loops[I].ForStmt ))
16390
- ? cast<ForStmt>(SeqAnalysis.Loops[I].ForStmt )->getBody()
16391
- : cast<CXXForRangeStmt>(SeqAnalysis.Loops[I].ForStmt )->getBody();
16388
+ (isa<ForStmt>(SeqAnalysis.Loops[I].TheForStmt ))
16389
+ ? cast<ForStmt>(SeqAnalysis.Loops[I].TheForStmt )->getBody()
16390
+ : cast<CXXForRangeStmt>(SeqAnalysis.Loops[I].TheForStmt )->getBody();
16392
16391
BodyStmts.push_back(Body);
16393
16392
16394
16393
CompoundStmt *CombinedBody =
@@ -16457,7 +16456,7 @@ StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef<OMPClause *> Clauses,
16457
16456
llvm::append_range(PreInits, TransformPreInit);
16458
16457
}
16459
16458
16460
- FinalLoops.push_back(SeqAnalysis.Loops[I].ForStmt );
16459
+ FinalLoops.push_back(SeqAnalysis.Loops[I].TheForStmt );
16461
16460
}
16462
16461
16463
16462
FinalLoops.insert(FinalLoops.begin() + (FirstVal - 1), FusedForStmt);
0 commit comments