[Openmp-commits] [clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation directive and "looprange" clause (PR #139293)
Alexey Bataev via Openmp-commits
openmp-commits at lists.llvm.org
Fri Aug 8 09:28:56 PDT 2025
Roger Ferrer =?utf-8?q?Ibáñez?= <rofirrim at gmail.com>,Roger Ferrer
Ibanez <roger.ferrer at bsc.es>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/139293 at github.com>
================
@@ -508,6 +512,43 @@ OMPInterchangeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
SourceLocation(), SourceLocation(), NumLoops);
}
+OMPFuseDirective *OMPFuseDirective::Create(
+ const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ ArrayRef<OMPClause *> Clauses, unsigned NumLoops, unsigned NumLoopNests,
+ Stmt *AssociatedStmt, Stmt *TransformedStmt, Stmt *PreInits) {
+
+ OMPFuseDirective *Dir = createDirective<OMPFuseDirective>(
+ C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,
+ NumLoops);
+ Dir->setTransformedStmt(TransformedStmt);
+ Dir->setPreInits(PreInits);
+ // The number of top level canonical nests could
+ // not match the total number of generated loops
+ // Example:
+ // Before fusion:
+ // for (int i = 0; i < N; ++i)
+ // for (int j = 0; j < M; ++j)
+ // A[i][j] = i + j;
+ //
+ // for (int k = 0; k < P; ++k)
+ // B[k] = k * 2;
+ // Here, NumLoopNests = 2, but NumLoops = 3.
----------------
alexey-bataev wrote:
Yep, not necessary to do it here, better in separate patch(es)
https://github.com/llvm/llvm-project/pull/139293
More information about the Openmp-commits
mailing list